Przeglądaj źródła

HADOOP-4282. Some user facing URLs are not filtered by user filters. (szetszwo)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@712875 13f79535-47bb-0310-9956-ffa450edef68
Tsz-wo Sze 16 lat temu
rodzic
commit
94d358f651

+ 3 - 0
CHANGES.txt

@@ -1077,6 +1077,9 @@ Release 0.19.0 - Unreleased
     to reflect the information being displayed. (Sreekanth Ramakrishnan via 
     yhemanth)
 
+    HADOOP-4282. Some user facing URLs are not filtered by user filters.
+    (szetszwo)
+
 Release 0.18.3 - Unreleased
 
   BUG FIXES

+ 4 - 5
src/core/org/apache/hadoop/http/HttpServer.java

@@ -212,16 +212,15 @@ public class HttpServer implements FilterContainer {
 
     final String[] USER_FACING_URLS = { "*.html", "*.jsp" };
     defineFilter(webAppContext, name, classname, parameters, USER_FACING_URLS);
+
+    final String[] ALL_URLS = { "/*" };
     for (Map.Entry<WebApplicationContext, Boolean> e : defaultContexts
         .entrySet()) {
       if (e.getValue()) {
         WebApplicationContext ctx = e.getKey();
-        defineFilter(ctx, name, classname, parameters, USER_FACING_URLS);
-        WebApplicationHandler handler = ctx.getWebApplicationHandler();
-        handler.addFilterPathMapping(ctx.getContextPath() + "/*", name,
-            Dispatcher.__ALL);
+        defineFilter(ctx, name, classname, parameters, ALL_URLS);
         LOG.info("Added filter " + name + " (class=" + classname
-            + ") to context path " + ctx.getContextPath() + "/*");
+            + ") to context " + ctx.getName());
       }
     }
     filterNames.add(name);

+ 7 - 3
src/test/org/apache/hadoop/http/TestServletFilter.java

@@ -110,9 +110,12 @@ public class TestServletFilter extends junit.framework.TestCase {
     final String fsckURL = "/fsck";
     final String stacksURL = "/stacks";
     final String ajspURL = "/a.jsp";
-    final String[] urls = {fsckURL, stacksURL, ajspURL};
+    final String logURL = "/logs/a.log";
+    final String hadooplogoURL = "/static/hadoop-logo.jpg";
+    
+    final String[] urls = {fsckURL, stacksURL, ajspURL, logURL, hadooplogoURL};
     final Random ran = new Random();
-    final int[] sequence = new int[20];
+    final int[] sequence = new int[50];
     final int[] counts = new int[urls.length]; 
 
     //generate a random sequence and update counts 
@@ -140,7 +143,8 @@ public class TestServletFilter extends junit.framework.TestCase {
       if (counts[i] == 0) {
         assertFalse(COUNTS.containsKey(urls[i]));
       } else {
-        assertEquals(counts[i], COUNTS.remove(urls[i]).intValue());
+        assertEquals("url[" + i + "]=" + urls[i],
+            Integer.valueOf(counts[i]), COUNTS.remove(urls[i]));
       }
     }
     assertTrue(COUNTS.isEmpty());