Return-Path: Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: (qmail 66638 invoked from network); 20 Dec 2009 17:53:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 20 Dec 2009 17:53:02 -0000 Received: (qmail 26085 invoked by uid 500); 20 Dec 2009 17:53:01 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 25988 invoked by uid 500); 20 Dec 2009 17:53:01 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 25977 invoked by uid 99); 20 Dec 2009 17:53:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 20 Dec 2009 17:53:01 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 20 Dec 2009 17:52:59 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 04278238898B; Sun, 20 Dec 2009 17:52:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r892624 - in /tomcat/tc5.5.x/trunk: STATUS.txt container/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java container/webapps/docs/changelog.xml Date: Sun, 20 Dec 2009 17:52:37 -0000 To: dev@tomcat.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091220175238.04278238898B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: markt Date: Sun Dec 20 17:52:37 2009 New Revision: 892624 URL: http://svn.apache.org/viewvc?rev=892624&view=rev Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=39844 Prevent NPE on non-HTTP forward Modified: tomcat/tc5.5.x/trunk/STATUS.txt tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml Modified: tomcat/tc5.5.x/trunk/STATUS.txt URL: http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/STATUS.txt?rev=892624&r1=892623&r2=892624&view=diff ============================================================================== --- tomcat/tc5.5.x/trunk/STATUS.txt (original) +++ tomcat/tc5.5.x/trunk/STATUS.txt Sun Dec 20 17:52:37 2009 @@ -33,12 +33,6 @@ 0: fhanik - big step for an old branch, could be risky, I'd wait until after next release if we consider it -1: -* Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=39844 - Port r588477 (fix for #43668) by billbarker that corrected this for Tomcat 6 - http://people.apache.org/~markt/patches/2009-07-11-bug39844.patch - +1: markt, kkolinko, rjung - -1: - * Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=43327 Port from 6.0.x Required to investigate 39997 Modified: tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java URL: http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java?rev=892624&r1=892623&r2=892624&view=diff ============================================================================== --- tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java (original) +++ tomcat/tc5.5.x/trunk/container/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java Sun Dec 20 17:52:37 2009 @@ -139,6 +139,16 @@ * Are we performing an include() instead of a forward()? */ boolean including = false; + + /** + * Outer most HttpServletRequest in the chain + */ + HttpServletRequest hrequest = null; + + /** + * Outermost HttpServletResponse in the chain + */ + HttpServletResponse hresponse = null; } // ----------------------------------------------------------- Constructors @@ -329,32 +339,17 @@ checkSameObjects(request, response); } - // Identify the HTTP-specific request and response objects (if any) - HttpServletRequest hrequest = null; - if (request instanceof HttpServletRequest) - hrequest = (HttpServletRequest) request; - HttpServletResponse hresponse = null; - if (response instanceof HttpServletResponse) - hresponse = (HttpServletResponse) response; - - // Handle a non-HTTP forward by passing the existing request/response - if ((hrequest == null) || (hresponse == null)) { - - if ( log.isDebugEnabled() ) - log.debug(" Non-HTTP Forward"); - - processRequest(hrequest,hresponse,state); - - } - + wrapResponse(state); + // Handle an HTTP named dispatcher forward - else if ((servletPath == null) && (pathInfo == null)) { + if ((servletPath == null) && (pathInfo == null)) { if ( log.isDebugEnabled() ) log.debug(" Named Dispatcher Forward"); ApplicationHttpRequest wrequest = (ApplicationHttpRequest) wrapRequest(state); + HttpServletRequest hrequest = state.hrequest; wrequest.setRequestURI(hrequest.getRequestURI()); wrequest.setContextPath(hrequest.getContextPath()); wrequest.setServletPath(hrequest.getServletPath()); @@ -374,6 +369,7 @@ (ApplicationHttpRequest) wrapRequest(state); String contextPath = context.getPath(); + HttpServletRequest hrequest = state.hrequest; if (hrequest.getAttribute(Globals.FORWARD_REQUEST_URI_ATTR) == null) { wrequest.setAttribute(Globals.FORWARD_REQUEST_URI_ATTR, hrequest.getRequestURI()); @@ -422,12 +418,12 @@ ServletOutputStream stream = response.getOutputStream(); stream.close(); } catch (IllegalStateException f) { - ; + // Ignore } catch (IOException f) { - ; + // Ignore } } catch (IOException e) { - ; + // Ignore } } @@ -513,23 +509,8 @@ // ServletResponse wresponse = null; wrapResponse(state); - // Handle a non-HTTP include - if (!(request instanceof HttpServletRequest) || - !(response instanceof HttpServletResponse)) { - - if ( log.isDebugEnabled() ) - log.debug(" Non-HTTP Include"); - request.setAttribute( - ApplicationFilterFactory.DISPATCHER_TYPE_ATTR, - new Integer(ApplicationFilterFactory.INCLUDE)); - request.setAttribute( - ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR, - servletPath); - invoke(request, state.outerResponse, state); - } - // Handle an HTTP named dispatcher include - else if (name != null) { + if (name != null) { if ( log.isDebugEnabled() ) log.debug(" Named Dispatcher Include"); @@ -621,7 +602,7 @@ } // Initialize local variables we may need - HttpServletResponse hresponse = (HttpServletResponse) response; + HttpServletResponse hresponse = state.hresponse; Servlet servlet = null; IOException ioException = null; ServletException servletException = null; @@ -651,7 +632,6 @@ wrapper.getLogger().error(sm.getString("applicationDispatcher.allocateException", wrapper.getName()), StandardWrapper.getRootCause(e)); servletException = e; - servlet = null; } catch (Throwable e) { wrapper.getLogger().error(sm.getString("applicationDispatcher.allocateException", wrapper.getName()), e); @@ -854,6 +834,8 @@ ServletRequest previous = null; ServletRequest current = state.outerRequest; while (current != null) { + if(state.hrequest == null && (current instanceof HttpServletRequest)) + state.hrequest = (HttpServletRequest)current; if ("org.apache.catalina.servlets.InvokerHttpRequest". equals(current.getClass().getName())) break; // KLUDGE - Make nested RD.forward() using invoker work @@ -915,6 +897,11 @@ ServletResponse previous = null; ServletResponse current = state.outerResponse; while (current != null) { + if(state.hresponse == null && (current instanceof HttpServletResponse)) { + state.hresponse = (HttpServletResponse)current; + if(!state.including) // Forward only needs hresponse + return null; + } if (!(current instanceof ServletResponseWrapper)) break; if (current instanceof ApplicationHttpResponse) Modified: tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml?rev=892624&r1=892623&r2=892624&view=diff ============================================================================== --- tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml (original) +++ tomcat/tc5.5.x/trunk/container/webapps/docs/changelog.xml Sun Dec 20 17:52:37 2009 @@ -71,6 +71,10 @@ (markt/kkolinko) + 39844: Fix NPE when performing a non-HTTP forward. + (billbarker) + + 41059: Reduce the chances of errors when using ENABLE_CLEAR_REFERENCES. Patch by Curt Arnold. (markt) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org