tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kfuj...@apache.org
Subject svn commit: r1345033 - in /tomcat/tc7.0.x/trunk: java/org/apache/catalina/core/ContainerBase.java webapps/docs/changelog.xml
Date Fri, 01 Jun 2012 09:48:59 GMT
Author: kfujino
Date: Fri Jun  1 09:48:58 2012
New Revision: 1345033

URL: http://svn.apache.org/viewvc?rev=1345033&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=53342
To avoid BindException, make startStopThreads into a demon thread.

Modified:
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/ContainerBase.java
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/ContainerBase.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/ContainerBase.java?rev=1345033&r1=1345032&r2=1345033&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/ContainerBase.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/ContainerBase.java Fri Jun  1 09:48:58
2012
@@ -31,8 +31,10 @@ import java.util.concurrent.BlockingQueu
 import java.util.concurrent.Callable;
 import java.util.concurrent.Future;
 import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -1084,7 +1086,8 @@ public abstract class ContainerBase exte
         startStopExecutor = new ThreadPoolExecutor(
                 getStartStopThreadsInternal(),
                 getStartStopThreadsInternal(), 10, TimeUnit.SECONDS,
-                startStopQueue);
+                startStopQueue,
+                new StartStopThreadFactory(getName() + "-startStop-"));
         startStopExecutor.allowCoreThreadTimeOut(true);
         super.initInternal();
     }
@@ -1584,4 +1587,24 @@ public abstract class ContainerBase exte
             return null;
         }
     }
+
+    private static class StartStopThreadFactory implements ThreadFactory {
+        private ThreadGroup group;
+        private AtomicInteger threadNumber = new AtomicInteger(1);
+        private String namePrefix;
+        
+        public StartStopThreadFactory(String namePrefix) {
+            SecurityManager s = System.getSecurityManager();
+            group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
+            this.namePrefix = namePrefix;
+        }
+        
+        @Override
+        public Thread newThread(Runnable r) {
+            Thread thread = new Thread(group, r, namePrefix + threadNumber.getAndIncrement());
+            thread.setDaemon(true);
+            return thread;
+        }
+    }
+
 }

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1345033&r1=1345032&r2=1345033&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Fri Jun  1 09:48:58 2012
@@ -169,6 +169,10 @@
         property name from its setter method if the name starts with several
         uppercase characters. (kkolinko)
       </fix>
+      <fix>
+        <bug>53342</bug>: To avoid BindException, make startStopThreads into
a
+        demon thread. (kfujino)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">



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


Mime
View raw message