You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "matthew.pope@criticalpath.net" <ma...@criticalpath.net> on 2005/05/30 22:09:50 UTC

Is there Patch for 4.1 PageContextImpl unhandled IllegalStateException?

Hello Tomcat Users and Committers, [duplicate as first msg got formatted incorrectly]Platform: Tomcat 4.1.24, Linux ES 2.1, jdk1.4.1.06Here is a snippet of the stack trace we regularly in our Tomcat 4.1.24 logs.----- Root Cause -----java.lang.IllegalStateException: getOutputStream() has already been called for this response        at org.apache.catalina.connector.ResponseBase.getWriter(ResponseBase.java:756)        at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:174)        at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:173)        at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:166)        at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:184)        at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:198)        at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:193)        at org.apache.jsp.ViewAttachment_jsp._jspService(ViewAttachment_jsp.java:76)We intend to migrate to Tomcat 5.x later this year.  In the interim, we recently linked this exception event to leaked memory.  That is, the PageContextImpl.release() method (6th from top in stack trace above, body below) never completes as it does not catch the IllegalStateException that happens when ResponseBase.getWriter()is called in the scope of 2nd  flushBuffer() call below.See org.apache.jasper.runtime.PageContextImpl:public void release() {    out = baseOut;    try {        if (isIncluded) {            ((JspWriterImpl)out).flushBuffer();            // push it into the including jspWriter        } else {            // Do not flush the buffer even if we're not included (i.e.            // we are the main page. The servlet will flush it and close            // the stream.            ((JspWriterImpl)out).flushBuffer();        }} catch (IOException ex) {    loghelper.log("Internal error flushing the buffer in release()");}servlet      = null;config	     = null;context	     = null;needsSession = false;errorPageURL = null;bufferSize   = JspWriter.DEFAULT_BUFFER;autoFlush    = true;request      = null;response     = null;       depth = -1;baseOut.recycle();session      = null;attributes.clear();}The 2nd last line above, session=null is skipped because of the uncaught exception, which creates a problem since a session so referenced becomes ineligible for garbage collection after processing the request.Does anyone know:a) is this a documented limitation (I read 102 matches for ‘memory leak’ on the Tomcat 4.1 list archives, but I did not find this exact problem, except for an entry in the 4.1 release notes where it is reported fixed in 4.1.20).b) is there a patch available to fix this in Tomcat 4.x?Thanks very much for your time,Matthew