You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2011/06/19 19:08:11 UTC

svn commit: r1137389 - /tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java

Author: markt
Date: Sun Jun 19 17:08:11 2011
New Revision: 1137389

URL: http://svn.apache.org/viewvc?rev=1137389&view=rev
Log:
Align with JIoEndpoint

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java?rev=1137389&r1=1137388&r2=1137389&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Sun Jun 19 17:08:11 2011
@@ -66,9 +66,6 @@ public class AprEndpoint extends Abstrac
 
     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 Abstrac
                     new SocketEventProcessor(wrapper, status);
                 ClassLoader loader = Thread.currentThread().getContextClassLoader();
                 try {
-                    if (IS_SECURITY_ENABLED) {
+                    if (Constants.IS_SECURITY_ENABLED) {
                         PrivilegedAction<Void> pa = new PrivilegedSetTccl(
                                 getClass().getClassLoader());
                         AccessController.doPrivileged(pa);
@@ -838,7 +835,7 @@ public class AprEndpoint extends Abstrac
                     }
                     getExecutor().execute(proc);
                 } finally {
-                    if (IS_SECURITY_ENABLED) {
+                    if (Constants.IS_SECURITY_ENABLED) {
                         PrivilegedAction<Void> pa = new PrivilegedSetTccl(loader);
                         AccessController.doPrivileged(pa);
                     } else {
@@ -866,7 +863,8 @@ public class AprEndpoint extends Abstrac
                     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<Void> pa = new PrivilegedSetTccl(
                                     getClass().getClassLoader());
                             AccessController.doPrivileged(pa);
@@ -874,9 +872,13 @@ public class AprEndpoint extends Abstrac
                             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<Void> pa = new PrivilegedSetTccl(loader);
                             AccessController.doPrivileged(pa);
                         } else {
@@ -886,7 +888,7 @@ public class AprEndpoint extends Abstrac
                 }
             }
         } 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);



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org