I think I found a bug in InvokerServlet.java.

The current code in the 4.0.3 for some reason removes a wrapper
that it may not have allocated from the context on exception in
wrapper.allocate().(pls, see code/comments below for explanation).

Problem manifests itself, if you have a servlet (let's call it MyServlet)
that is
run via InvokerServlet (i.e. http://host/servlet/myServlet) and you want to
assign some init-params to MyServlet via web.xml. If MyServlet generates
an exception in its init() method it will be removed from the context and
all
of its parameters will be dropped as well. So if invoked again without
restarting the server, the wrapper will be recreated with and empty
parameter
list.

I've tested a simple fix that removes suspect line:

    context.removeChild(wrapper);

It works. If my thinking is correct could someone tell me how
to get this change into a CVS tree.

Thanks, KN


public final class InvokerServlet
    extends HttpServlet implements ContainerServlet {
...
    public void serveRequest(HttpServletRequest request,
                             HttpServletResponse response)
        throws IOException, ServletException
    {
    ...
        Wrapper wrapper = null;
        ...
        wrapper = (Wrapper) context.findChild(servletClass);
        ...
         if (wrapper != null) {
            // goes here if you put a <servlet> </servlet> section in the
web.xml
            ...
            context.addServletMapping(pattern, wrapper.getName());
        } else {
            // creation of wrapper if doesn't exists
            wrapper = context.createWrapper();
            ...
            context.addChild(wrapper);
            context.addServletMapping(pattern, name);
            ...
         }

        try
        {
            instance = wrapper.allocate();
        } catch(ServletException e)
        {
            context.removeServletMapping(pattern); // ok, paired with
addServletMapping above
            context.removeChild(wrapper); // PROBLEM! should not be called
if we did not created the wrapper.
        }
    }
...
}



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to