Author: markt
Date: Thu Apr  9 09:13:28 2009
New Revision: 763566

URL: http://svn.apache.org/viewvc?rev=763566&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=46997
Code clean up
Patch provided by Jens Kapitza 

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/threads/TaskQueue.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/threads/TaskQueue.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/threads/TaskQueue.java?rev=763566&r1=763565&r2=763566&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/threads/TaskQueue.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/threads/TaskQueue.java Thu Apr  9 
09:13:28 2009
@@ -30,7 +30,7 @@
  *
  */
 public class TaskQueue extends LinkedBlockingQueue<Runnable> {
-    ThreadPoolExecutor parent = null;
+    private ThreadPoolExecutor parent = null;
 
     public TaskQueue() {
         super();
@@ -59,15 +59,13 @@
     }
 
     public boolean offer(Runnable o) {
-        //we can't do any checks
-        if (parent==null) return super.offer(o);
-        //we are maxed out on threads, simply queue the object
-        if (parent.getPoolSize() == parent.getMaximumPoolSize()) return 
super.offer(o);
-        //we have idle threads, just add it to the queue
-        if (parent.getActiveCount()<(parent.getPoolSize())) return 
super.offer(o);
-        //if we have less threads than maximum force creation of a new thread
-        if (parent.getPoolSize()<parent.getMaximumPoolSize()) return false;
-        //if we reached here, we need to add it to the queue
-        return super.offer(o);
+        if (parent != null && 
parent.getPoolSize()<parent.getMaximumPoolSize()){
+               return false;
+        } else {
+            //if we reached here, we need to add it to the queue
+            //or can't do any checks
+            return super.offer(o);
+        }
+
     }
 }



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

Reply via email to