Przeglądaj źródła

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

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-security@1204266 13f79535-47bb-0310-9956-ffa450edef68
Eli Collins 13 lat temu
rodzic
commit
194d7a34a7

+ 3 - 0
CHANGES.txt

@@ -43,6 +43,9 @@ Release 0.20.206.0 - unreleased
     HDFS-2541. For a sufficiently large value of blocks, the DN Scanner 
     may request a random number with a negative seed value. (harsh via eli)
 
+    MAPREDUCE-2377. task-controller fails to parse configuration if it
+    doesn't end in \n. (todd via eli)
+
   IMPROVEMENTS
 
     MAPREDUCE-2836. Provide option to fail jobs when submitted to

+ 6 - 2
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
src/c++/task-controller/test/test-task-controller.c

@@ -97,7 +97,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;
 }