Browse Source

HADOOP-309. Fix some NullPointerExceptions in the StatusHttpServer. Contributed by navychen.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@502749 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 18 years ago
parent
commit
104c9e53c3
2 changed files with 13 additions and 6 deletions
  1. 3 0
      CHANGES.txt
  2. 10 6
      src/java/org/apache/hadoop/mapred/StatusHttpServer.java

+ 3 - 0
CHANGES.txt

@@ -143,6 +143,9 @@ Trunk (unreleased changes)
 44. HADOOP-965.  Fix IsolationRunner so that job's jar can be found.
     (Dennis Kubes via cutting)
 
+45. HADOOP-309.  Fix two NullPointerExceptions in StatusHttpServer.
+    (navychen via cutting)
+
 
 Release 0.10.1 - 2007-01-10
 

+ 10 - 6
src/java/org/apache/hadoop/mapred/StatusHttpServer.java

@@ -70,13 +70,15 @@ public class StatusHttpServer {
     listener.setHost(bindAddress);
     webServer.addListener(listener);
 
-    // set up the context for "/logs/"
-    HttpContext logContext = new HttpContext();
-    logContext.setContextPath("/logs/*");
+    // set up the context for "/logs/" if "hadoop.log.dir" property is defined. 
     String logDir = System.getProperty("hadoop.log.dir");
-    logContext.setResourceBase(logDir);
-    logContext.addHandler(new ResourceHandler());
-    webServer.addContext(logContext);
+    if( logDir != null ) {
+      HttpContext logContext = new HttpContext();
+      logContext.setContextPath("/logs/*");
+      logContext.setResourceBase(logDir);
+      logContext.addHandler(new ResourceHandler());
+      webServer.addContext(logContext);
+    }
 
     // set up the context for "/static/*"
     String appDir = getWebAppsPath();
@@ -151,6 +153,8 @@ public class StatusHttpServer {
    */
   private static String getWebAppsPath() throws IOException {
     URL url = StatusHttpServer.class.getClassLoader().getResource("webapps");
+    if( url == null ) 
+      throw new IOException("webapps not found in CLASSPATH"); 
     String path = url.getPath();
     if (isWindows && path.startsWith("/")) {
       path = path.substring(1);