[ 
https://issues.apache.org/jira/browse/FELIX-5302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15366359#comment-15366359
 ] 

Derek Baum commented on FELIX-5302:
-----------------------------------

I'm afraid that didn't work. The duplicates are being added by different 
instances of the WhiteboardServiceTracker.

There is a single instance of the WhiteboardManager in both cases.


The "good" case looks like:

manager.start context1
adding service id=24 ServletTracker@3b3af66
manager.stop
manager.start context2
adding service id=26 ServletTracker@6b419013


while the "bad" case looks like:

manager.start context1
adding service id=24 ServletTracker@7245c93a
adding service id=26 ServletTracker@7245c93a
manager.stop
manager.start context2
adding service id=26 ServletTracker@5240ac63


The difference is that in the bad case, service id=26 was added by 
ServletTracker@7245c93a from the first start(context1) and then added again 
from the second start(context2) from ServletTracker@5240ac63.






> 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
>            Assignee: Carsten Ziegeler
>             Fix For: http.jetty-3.2.2
>
>         Attachments: http.jetty.bad.log, http.jetty.good.log
>
>
> 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)

Reply via email to