hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From umamah...@apache.org
Subject svn commit: r1386776 - in /hadoop/common/branches/branch-1: CHANGES.txt src/core/org/apache/hadoop/http/HttpServer.java src/test/org/apache/hadoop/http/TestServletFilter.java
Date Mon, 17 Sep 2012 19:08:18 GMT
Author: umamahesh
Date: Mon Sep 17 19:08:17 2012
New Revision: 1386776

URL: http://svn.apache.org/viewvc?rev=1386776&view=rev
Log:
HADOOP-8786. HttpServer continues to start even if AuthenticationFilter fails to init. Contributed
by Todd Lipcon.


Modified:
    hadoop/common/branches/branch-1/CHANGES.txt
    hadoop/common/branches/branch-1/src/core/org/apache/hadoop/http/HttpServer.java
    hadoop/common/branches/branch-1/src/test/org/apache/hadoop/http/TestServletFilter.java

Modified: hadoop/common/branches/branch-1/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/CHANGES.txt?rev=1386776&r1=1386775&r2=1386776&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/CHANGES.txt (original)
+++ hadoop/common/branches/branch-1/CHANGES.txt Mon Sep 17 19:08:17 2012
@@ -234,6 +234,9 @@ Release 1.2.0 - unreleased
     HADOOP-7688. When a servlet filter throws an exception in init(..), 
     the Jetty server failed silently.(umamahesh)
 
+    HADOOP-8786. HttpServer continues to start even if AuthenticationFilter 
+    fails to init. (Todd Lipcon via umamahesh)
+
 Release 1.1.0 - unreleased
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/branches/branch-1/src/core/org/apache/hadoop/http/HttpServer.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/core/org/apache/hadoop/http/HttpServer.java?rev=1386776&r1=1386775&r2=1386776&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/core/org/apache/hadoop/http/HttpServer.java (original)
+++ hadoop/common/branches/branch-1/src/core/org/apache/hadoop/http/HttpServer.java Mon Sep
17 19:08:17 2012
@@ -658,6 +658,16 @@ public class HttpServer implements Filte
               "Problem in starting http server. Server handlers failed");
         }
       }
+      
+      // Make sure there are no errors initializing the context.
+      Throwable unavailableException = webAppContext.getUnavailableException();
+      if (unavailableException != null) {
+        // Have to stop the webserver, or else its non-daemon threads
+        // will hang forever.
+        webServer.stop();
+        throw new IOException("Unable to initialize WebAppContext",
+            unavailableException);
+      }
     } catch (IOException e) {
       throw e;
     } catch (Exception e) {

Modified: hadoop/common/branches/branch-1/src/test/org/apache/hadoop/http/TestServletFilter.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/test/org/apache/hadoop/http/TestServletFilter.java?rev=1386776&r1=1386775&r2=1386776&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/test/org/apache/hadoop/http/TestServletFilter.java
(original)
+++ hadoop/common/branches/branch-1/src/test/org/apache/hadoop/http/TestServletFilter.java
Mon Sep 17 19:08:17 2012
@@ -154,7 +154,7 @@ public class TestServletFilter extends j
   @Test
   public void testServletFilterWhenInitThrowsException() throws Exception {
     Configuration conf = new Configuration();
-    // start a http server with CountingFilter
+    // start a http server with ErrorFilter
     conf.set(HttpServer.FILTER_INITIALIZER_PROPERTY,
         ErrorFilter.Initializer.class.getName());
     HttpServer http = new HttpServer("datanode", "localhost", 0, true, conf);
@@ -166,4 +166,23 @@ public class TestServletFilter extends j
           "Problem in starting http server. Server handlers failed"));
     }
   }
+  
+  /**
+   * Similar to the above test case, except that it uses a different API to add
+   * the filter. Regression test for HADOOP-8786.
+   */
+  @Test
+  public void testContextSpecificServletFilterWhenInitThrowsException()
+      throws Exception {
+    Configuration conf = new Configuration();
+    HttpServer http = new HttpServer("datanode", "localhost", 0, true, conf);
+    http.defineFilter(http.webAppContext, "ErrorFilter", ErrorFilter.class
+        .getName(), null, null);
+    try {
+      http.start();
+      fail("expecting exception");
+    } catch (IOException e) {
+      assertTrue(e.getMessage().contains("Unable to initialize WebAppContext"));
+    }
+  }
 }



Mime
View raw message