浏览代码

HADOOP-1137. Fix StatusHttpServer to work correctly when resources are in a jar file. Contributed by Benjamin Reed.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@521912 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 18 年之前
父节点
当前提交
4900b1d02d
共有 2 个文件被更改,包括 6 次插入11 次删除
  1. 3 0
      CHANGES.txt
  2. 3 11
      src/java/org/apache/hadoop/mapred/StatusHttpServer.java

+ 3 - 0
CHANGES.txt

@@ -24,6 +24,9 @@ Trunk (unreleased changes)
  7. HADOOP-1064.  Reduce log level of some DFSClient messages.
     (Dhruba Borthakur via cutting)
 
+ 8. HADOOP-1137.  Fix StatusHttpServer to work correctly when
+    resources are in a jar file.  (Benjamin Reed via cutting)
+
 
 Release 0.12.2 - 2007-23-17
 

+ 3 - 11
src/java/org/apache/hadoop/mapred/StatusHttpServer.java

@@ -84,7 +84,7 @@ public class StatusHttpServer {
     String appDir = getWebAppsPath();
     HttpContext staticContext = new HttpContext();
     staticContext.setContextPath("/static/*");
-    staticContext.setResourceBase(appDir + File.separator + "static");
+    staticContext.setResourceBase(appDir + "/static");
     staticContext.addHandler(new ResourceHandler());
     webServer.addContext(staticContext);
 
@@ -149,21 +149,13 @@ public class StatusHttpServer {
   
   /**
    * Get the pathname to the webapps files.
-   * @return the pathname
+   * @return the pathname as a URL
    */
   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);
-      try {
-        path = URLDecoder.decode(path, "UTF-8");
-      } catch (UnsupportedEncodingException e) {
-      }
-    }
-    return new File(path).getCanonicalPath();
+    return url.toString();
   }
   
   /**