Return-Path: X-Original-To: apmail-tomcat-dev-archive@www.apache.org Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3CC9411FBF for ; Wed, 6 Aug 2014 19:08:32 +0000 (UTC) Received: (qmail 88382 invoked by uid 500); 6 Aug 2014 19:08:31 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 88315 invoked by uid 500); 6 Aug 2014 19:08:31 -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 88300 invoked by uid 99); 6 Aug 2014 19:08:31 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Aug 2014 19:08:31 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.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; Wed, 06 Aug 2014 19:08:32 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A30C923892FF for ; Wed, 6 Aug 2014 19:08:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1616309 - /tomcat/trunk/java/org/apache/catalina/core/StandardHostValve.java Date: Wed, 06 Aug 2014 19:08:07 -0000 To: dev@tomcat.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140806190807.A30C923892FF@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: markt Date: Wed Aug 6 19:08:07 2014 New Revision: 1616309 URL: http://svn.apache.org/r1616309 Log: Ensure unbind() is always called after calling bind() Modified: tomcat/trunk/java/org/apache/catalina/core/StandardHostValve.java Modified: tomcat/trunk/java/org/apache/catalina/core/StandardHostValve.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardHostValve.java?rev=1616309&r1=1616308&r2=1616309&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/core/StandardHostValve.java (original) +++ tomcat/trunk/java/org/apache/catalina/core/StandardHostValve.java Wed Aug 6 19:08:07 2014 @@ -127,57 +127,59 @@ final class StandardHostValve extends Va // ensure an infinite error handling loop is not entered boolean errorAtStart = response.isError(); - context.bind(Globals.IS_SECURITY_ENABLED, MY_CLASSLOADER); + try { + context.bind(Globals.IS_SECURITY_ENABLED, MY_CLASSLOADER); - if (asyncAtStart || context.fireRequestInitEvent(request)) { + if (asyncAtStart || context.fireRequestInitEvent(request)) { - // Ask this Context to process this request - try { - context.getPipeline().getFirst().invoke(request, response); - } catch (Throwable t) { - ExceptionUtils.handleThrowable(t); - if (errorAtStart) { - container.getLogger().error("Exception Processing " + - request.getRequestURI(), t); - } else { - request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t); - throwable(request, response, t); + // Ask this Context to process this request + try { + context.getPipeline().getFirst().invoke(request, response); + } catch (Throwable t) { + ExceptionUtils.handleThrowable(t); + if (errorAtStart) { + container.getLogger().error("Exception Processing " + + request.getRequestURI(), t); + } else { + request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t); + throwable(request, response, t); + } } - } - Throwable t = (Throwable) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION); + Throwable t = (Throwable) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION); - // If the request was async at the start and an error occurred then - // the async error handling will kick-in and that will fire the - // request destroyed event *after* the error handling has taken - // place - if (!(request.isAsync() || (asyncAtStart && t != null))) { - // Protect against NPEs if context was destroyed during a - // long running request. - if (context.getState().isAvailable()) { - if (!errorAtStart) { - // Error page processing - response.setSuspended(false); - - if (t != null) { - throwable(request, response, t); - } else { - status(request, response); + // If the request was async at the start and an error occurred + // then the async error handling will kick-in and that will fire + // the request destroyed event *after* the error handling has + // taken place. + if (!(request.isAsync() || (asyncAtStart && t != null))) { + // Protect against NPEs if context was destroyed during a + // long running request. + if (context.getState().isAvailable()) { + if (!errorAtStart) { + // Error page processing + response.setSuspended(false); + + if (t != null) { + throwable(request, response, t); + } else { + status(request, response); + } } - } - context.fireRequestDestroyEvent(request); + context.fireRequestDestroyEvent(request); + } } } - } - // Access a session (if present) to update last accessed time, based on a - // strict interpretation of the specification - if (ACCESS_SESSION) { - request.getSession(false); + // Access a session (if present) to update last accessed time, based + // on a strict interpretation of the specification + if (ACCESS_SESSION) { + request.getSession(false); + } + } finally { + context.unbind(Globals.IS_SECURITY_ENABLED, MY_CLASSLOADER); } - - context.unbind(Globals.IS_SECURITY_ENABLED, MY_CLASSLOADER); } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org