dev@glassfish.java.net

one more memory leak risk

From: Roman Pokhodzhai <rpohod_at_gmail.com>
Date: Fri, 20 Feb 2009 10:05:41 +0200

Hi , All,

I found defect in code which provoke PermGen memory leak problem.

*org.apache.catalina.core.StandardHostValve.postInvoke()*. If response is
committed the context class loader of the current thread (which is set to
the application class loader in *
org.apache.catalina.core.StandardHostValve.invoke()*) is never unset. This
causes a thread to hang on to our application class loader even after the
application is undeployed.



    public void postInvoke(Request request, Response response)

        // START SJSAS 6374691

        throws IOException, ServletException

        // END SJSAS 6374691

    {

        // START SJSAS 6374990

* if (((ServletResponse) response).isCommitted()) {*

* return;*

* }*

        // END SJSAS 6374990



        HttpServletRequest hreq = (HttpServletRequest) request.getRequest();

        // END OF IASRI 4665318

        // Error page processing

        response.setSuspended(false);



        Throwable t = (Throwable) hreq.getAttribute(Globals.EXCEPTION_ATTR);



        if (t != null) {

            throwable(request, response, t);

        } else {

            status(request, response);

        }



* Thread.currentThread().setContextClassLoader*

* (standardHostValveClassLoader);*



        // START SJSAS 6374691

        if (errorReportValve != null) {

            errorReportValve.postInvoke(request, response);

        }

        // END SJSAS 6374691

    }


Any suggestions?