From f6f9a76275448d65ffc64cb3bcd55fed0b997774 Mon Sep 17 00:00:00 2001 From: markt Date: Sun, 19 Jun 2011 17:08:11 +0000 Subject: [PATCH] Align with JIoEndpoint git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1137389 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/tomcat/util/net/AprEndpoint.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/java/org/apache/tomcat/util/net/AprEndpoint.java b/java/org/apache/tomcat/util/net/AprEndpoint.java index 96ec4a6fa..f629171f8 100644 --- a/java/org/apache/tomcat/util/net/AprEndpoint.java +++ b/java/org/apache/tomcat/util/net/AprEndpoint.java @@ -66,9 +66,6 @@ public class AprEndpoint extends AbstractEndpoint { private static final Log log = LogFactory.getLog(AprEndpoint.class); - private static final boolean IS_SECURITY_ENABLED = - (System.getSecurityManager() != null); - // ----------------------------------------------------------------- Fields /** * Root APR memory pool. @@ -828,7 +825,7 @@ public class AprEndpoint extends AbstractEndpoint { new SocketEventProcessor(wrapper, status); ClassLoader loader = Thread.currentThread().getContextClassLoader(); try { - if (IS_SECURITY_ENABLED) { + if (Constants.IS_SECURITY_ENABLED) { PrivilegedAction pa = new PrivilegedSetTccl( getClass().getClassLoader()); AccessController.doPrivileged(pa); @@ -838,7 +835,7 @@ public class AprEndpoint extends AbstractEndpoint { } getExecutor().execute(proc); } finally { - if (IS_SECURITY_ENABLED) { + if (Constants.IS_SECURITY_ENABLED) { PrivilegedAction pa = new PrivilegedSetTccl(loader); AccessController.doPrivileged(pa); } else { @@ -866,7 +863,8 @@ public class AprEndpoint extends AbstractEndpoint { SocketProcessor proc = new SocketProcessor(socket, status); ClassLoader loader = Thread.currentThread().getContextClassLoader(); try { - if (IS_SECURITY_ENABLED) { + //threads should not be created by the webapp classloader + if (Constants.IS_SECURITY_ENABLED) { PrivilegedAction pa = new PrivilegedSetTccl( getClass().getClassLoader()); AccessController.doPrivileged(pa); @@ -874,9 +872,13 @@ public class AprEndpoint extends AbstractEndpoint { Thread.currentThread().setContextClassLoader( getClass().getClassLoader()); } + // During shutdown, executor may be null - avoid NPE + if (!running) { + return false; + } getExecutor().execute(proc); } finally { - if (IS_SECURITY_ENABLED) { + if (Constants.IS_SECURITY_ENABLED) { PrivilegedAction pa = new PrivilegedSetTccl(loader); AccessController.doPrivileged(pa); } else { @@ -886,7 +888,7 @@ public class AprEndpoint extends AbstractEndpoint { } } } catch (RejectedExecutionException x) { - log.warn("Socket processing request was rejected for:"+socket,x); + log.warn("Socket processing request was rejected for: "+socket, x); return false; } catch (Throwable t) { ExceptionUtils.handleThrowable(t); -- 2.11.0