Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 322575

Summary: NPE in HotSwapHandler if changing handler when started and no old handler set
Product: [RT] Jetty Reporter: Gunnar Wagenknecht <gunnar>
Component: serverAssignee: Jesse McConnell <jesse.mcconnell>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jetty-inbox, mgorovoy
Version: 7.1.4   
Target Milestone: 7.1.x   
Hardware: All   
OS: All   
Whiteboard:

Description Gunnar Wagenknecht CLA 2010-08-12 15:06:38 EDT
java.lang.NullPointerException
	at org.eclipse.jetty.server.handler.HotSwapHandler.setHandler(HotSwapHandler.java:84)
	at org.eclipse.gyrex.http.jetty.internal.app.UrlToApplicationHandler$ApplicationDelegator.handle(UrlToApplicationHandler.java:53)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:932)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:870)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:214)
	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:113)
	at org.eclipse.jetty.server.Server.handle(Server.java:333)
	at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:595)
	at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:1038)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:549)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:211)
	at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:424)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:489)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:436)
	at java.lang.Thread.run(Thread.java:619)


old_handler maybe null in that case if not set before but already started. Workaround is to set a handler first before starting.
Comment 1 Jesse McConnell CLA 2010-08-16 12:02:25 EDT
> svn commit -m "Bug 322575 resolve potential NPE in hot swap handler if old handler was null.  added a null check since existing doStart and doStop methods specifically handle cases where wrapped handler is null on start/stop" 

VERSION.txt 
jetty-server/src/main/java/org/eclipse/jetty/server/handler/HotSwapHandler.java

Committed revision 2216.
Comment 2 Gunnar Wagenknecht CLA 2010-08-16 12:08:14 EDT
Sweet. That was fast. :)