Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 356751 - Add null protection to ServletContextHandler.doStop
Summary: Add null protection to ServletContextHandler.doStop
Status: RESOLVED FIXED
Alias: None
Product: Jetty
Classification: RT
Component: server (show other bugs)
Version: 7.5.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 7.5.x   Edit
Assignee: Jan Bartel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-05 19:20 EDT by Jan Bartel CLA
Modified: 2011-09-05 19:26 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Bartel CLA 2011-09-05 19:20:34 EDT
Below is a cut n paste of a problem encountered by a user on the jetty lists. Although not a jetty bug per se, its worth adding some null checks on the doStop for ServletContextHandler:


Hi,
it turns out that my main handler had not started up and hence jetty was probably in a sort of inconsistent status.

I think it'd be easy to be protected against that situation though, maybe we can simply check for null in the "doStop" method below?

thanks,
Michele

    ------------------------------


    Michele,

    What is your code that sets up and starts jetty?

    Jan

    On 2 September 2011 18:06, Michele Rossi <michele.rossi@gmail.com> wrote:
    > Hi,
    > I have just tried out the latest build of Jetty available on maven, 7.5.0
    > 20110901 and I am getting the following exception when attempting to call
    > Server.stop().
    >
    > java.lang.NullPointerException
    > ??? at
    > org.eclipse.jetty.servlet.ServletContextHandler.doStop(ServletContextHandler.java:146)
    > ??? at org.eclipse.jetty.webapp.WebAppContext.doStop(WebAppContext.java:477)
    > ??? at
    > org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:84)
    > ??? at
    > org.eclipse.jetty.server.handler.HandlerCollection.doStop(HandlerCollection.java:245)
    > ??? at
    > org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:84)
    > ??? at
    > org.eclipse.jetty.server.handler.HandlerWrapper.doStop(HandlerWrapper.java:101)
    > ??? at org.eclipse.jetty.server.Server.doStop(Server.java:322)
    > ??? at
    > org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:84)
    >
    > The method in question is
    >
    > ??? @Override
    > ??? protected void doStop() throws Exception
    > ??? {
    > ??????? super.doStop();
    > ??????? _decorators.clear();
    > ??????? _wrapper.setHandler(null);
    > ??? }
    >
    > and _wrapper is null.
    >
    >
Comment 1 Jan Bartel CLA 2011-09-05 19:26:53 EDT
Null checks add to doStop. Fixed for jetty-7.5.1