Derek Baum created FELIX-5302:
---------------------------------
Summary: NPE using Http Whiteboard
Key: FELIX-5302
URL: https://issues.apache.org/jira/browse/FELIX-5302
Project: Felix
Issue Type: Bug
Components: HTTP Service
Affects Versions: http.jetty-3.2.0
Reporter: Derek Baum
I am getting this NPE about 50% of the time after reconfiguring my servlet
(causing it to unregister and re-register):
[org.apache.felix.http.jetty:3.2.0] Exception while processing request to
/hello/sayHello
java.lang.NullPointerException: null
org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:85)
org.apache.felix.http.base.internal.dispatch.InvocationChain.doFilter(InvocationChain.java:79)
org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:124)
org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:61)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:845)
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)
org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:224)
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1160)
org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)
org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1092)
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213)
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
org.eclipse.jetty.server.Server.handle(Server.java:518)
org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:308)
org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:244)
org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273)
org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)
org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:246)
org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:156)
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
java.lang.Thread.run(Thread.java:745)
The servlet uses the Http Whiteboard:
@Component(
property = {
HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN + "=/hello/sayHello",
HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PATTERN +
"=/hello/static/*",
HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX + "=/static"})
public class HelloWorldServlet extends HttpServlet implements Servlet {
}
About 50% of the time when I initially deploy the Servlet, I've noticed that
ServletRegistry.addServlet() is called twice for the same servlet with the same
serviceId.
I don't know why this happens, but when it does it leads to the NPE above.
The second addServlet() invokes addToInactiveList().
The system works in this state, but it has a duplicate servlet handler in the
inactive list.
If the servlet is now reconfigured, causing it to unregister and re-register,
we get the NPE above on the next request.
This appears to be because ServletRegistry.removeServlet() fails to invoke
"resolvers.remove(regHandler)", when the inactive list contains the argument
ServletInfo.
Alternatively, addServlet() should never allow a duplicate registration to be
added to the inactive list.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)