HADOOP-7688. Add servlet handler check in HttpServer.start(). Contributed by Uma Maheswara Rao G
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1198924 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
00b5aa76f9
commit
a83753b735
@ -55,7 +55,10 @@ Trunk (unreleased changes)
|
|||||||
HADOOP-7792. Add verifyToken method to AbstractDelegationTokenSecretManager.
|
HADOOP-7792. Add verifyToken method to AbstractDelegationTokenSecretManager.
|
||||||
(jitendra)
|
(jitendra)
|
||||||
|
|
||||||
HADOOP-7776 Make the Ipc-Header in a RPC-Payload an explicit header (sanjay)
|
HADOOP-7776 Make the Ipc-Header in a RPC-Payload an explicit header (sanjay)
|
||||||
|
|
||||||
|
HADOOP-7688. Add servlet handler check in HttpServer.start().
|
||||||
|
(Uma Maheswara Rao G via szetszwo)
|
||||||
|
|
||||||
BUGS
|
BUGS
|
||||||
|
|
||||||
|
@ -707,6 +707,14 @@ public void start() throws IOException {
|
|||||||
listener.setPort((oriPort += 1));
|
listener.setPort((oriPort += 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Make sure there is no handler failures.
|
||||||
|
Handler[] handlers = webServer.getHandlers();
|
||||||
|
for (int i = 0; i < handlers.length; i++) {
|
||||||
|
if (handlers[i].isFailed()) {
|
||||||
|
throw new IOException(
|
||||||
|
"Problem in starting http server. Server handlers failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
@ -45,7 +45,7 @@ public class TestServletFilter extends HttpServerFunctionalTest {
|
|||||||
static public class SimpleFilter implements Filter {
|
static public class SimpleFilter implements Filter {
|
||||||
private FilterConfig filterConfig = null;
|
private FilterConfig filterConfig = null;
|
||||||
|
|
||||||
public void init(FilterConfig filterConfig) {
|
public void init(FilterConfig filterConfig) throws ServletException {
|
||||||
this.filterConfig = filterConfig;
|
this.filterConfig = filterConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,4 +137,36 @@ public void testServletFilter() throws Exception {
|
|||||||
http.stop();
|
http.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public class ErrorFilter extends SimpleFilter {
|
||||||
|
@Override
|
||||||
|
public void init(FilterConfig arg0) throws ServletException {
|
||||||
|
throw new ServletException("Throwing the exception from Filter init");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Configuration for the filter */
|
||||||
|
static public class Initializer extends FilterInitializer {
|
||||||
|
public Initializer() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initFilter(FilterContainer container, Configuration conf) {
|
||||||
|
container.addFilter("simple", ErrorFilter.class.getName(), null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testServletFilterWhenInitThrowsException() throws Exception {
|
||||||
|
Configuration conf = new Configuration();
|
||||||
|
// start a http server with CountingFilter
|
||||||
|
conf.set(HttpServer.FILTER_INITIALIZER_PROPERTY,
|
||||||
|
ErrorFilter.Initializer.class.getName());
|
||||||
|
HttpServer http = createTestServer(conf);
|
||||||
|
try {
|
||||||
|
http.start();
|
||||||
|
fail("expecting exception");
|
||||||
|
} catch (IOException e) {
|
||||||
|
assertTrue( e.getMessage().contains("Problem in starting http server. Server handlers failed"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user