Jelajahi Sumber

MAPREDUCE-2377. task-controller fails to parse configuration if it doesn't end in \n. Contributed by Todd Lipcon and Benoy Antony.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.22@1346251 13f79535-47bb-0310-9956-ffa450edef68
Konstantin Shvachko 13 tahun lalu
induk
melakukan
e0ff93a292

+ 3 - 0
mapreduce/CHANGES.txt

@@ -53,6 +53,9 @@ Release 0.22.1 - Unreleased
     MAPREDUCE-2353. MR changes to reflect the API changes in SecureIO library.
     (Devaraj Das and Benoy Antony via shv)
 
+    MAPREDUCE-2377. task-controller fails to parse configuration if it doesn't
+    end in \n. (Todd Lipcon and Benoy Antony via shv)
+
 Release 0.22.0 - 2011-11-29
 
   INCOMPATIBLE CHANGES

+ 6 - 2
mapreduce/src/c++/task-controller/impl/configuration.c

@@ -155,8 +155,12 @@ void read_config(const char* file_name) {
         break;
       }
     }
-    //trim the ending new line
-    line[strlen(line)-1] = '\0';
+
+    //trim the ending new line if there is one
+    if (line[strlen(line) - 1] == '\n') {
+        line[strlen(line)-1] = '\0';
+    }
+
     //comment line
     if(line[0] == '#') {
       free(line);

+ 1 - 1
mapreduce/src/c++/task-controller/test/test-task-controller.c

@@ -95,7 +95,7 @@ int write_config_file(char *file_name) {
     fprintf(file, "," TEST_ROOT "/local-%d", i);
   }
   fprintf(file, "\n");
-  fprintf(file, "hadoop.log.dir=" TEST_ROOT "/logs\n");
+  fprintf(file, "hadoop.log.dir=" TEST_ROOT "/logs");
   fclose(file);
   return 0;
 }