소스 검색

merge MAPREDUCE-3930 from trunk

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1294903 13f79535-47bb-0310-9956-ffa450edef68
Siddharth Seth 13 년 전
부모
커밋
4f586249ac

+ 4 - 0
hadoop-mapreduce-project/CHANGES.txt

@@ -126,6 +126,10 @@ Release 0.23.2 - UNRELEASED
     MAPREDUCE-3816. capacity scheduler web ui bar graphs for used capacity wrong
     (tgraves via bobby)
 
+    MAPREDUCE-3930. Fixed an NPE while accessing the AM page/webservice for a 
+    task attempt without an assigned container. (Robert Joseph Evans via
+    sseth)
+
 Release 0.23.1 - 2012-02-17 
 
   NEW FEATURES

+ 1 - 1
hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ConverterUtils.java

@@ -142,7 +142,7 @@ public class ConverterUtils {
   }
 
   public static String toString(ContainerId cId) {
-    return cId.toString();
+    return cId == null ? null : cId.toString();
   }
 
   public static NodeId toNodeId(String nodeIdStr) {

+ 14 - 0
hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestConverterUtils.java

@@ -22,6 +22,7 @@ import static org.junit.Assert.*;
 import java.net.URISyntaxException;
 
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.URL;
 import org.junit.Test;
 
@@ -35,4 +36,17 @@ public class TestConverterUtils {
     assertEquals(expectedPath, actualPath);
   }
 
+  @Test
+  public void testContainerId() throws URISyntaxException {
+    ContainerId id = BuilderUtils.newContainerId(0, 0, 0, 0);
+    String cid = ConverterUtils.toString(id);
+    assertEquals("container_0_0000_00_000000", cid);
+    ContainerId gen = ConverterUtils.toContainerId(cid);
+    assertEquals(gen, id);
+  }
+
+  @Test
+  public void testContainerIdNull() throws URISyntaxException {
+    assertNull(ConverterUtils.toString((ContainerId)null));
+  }  
 }