Fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=47161
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 15 Sep 2009 21:06:14 +0000 (21:06 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 15 Sep 2009 21:06:14 +0000 (21:06 +0000)
Correctly report maxThreads
Note 6.0.x will need a different fix as it still uses threadpools

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@815486 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/tomcat/util/net/AbstractEndpoint.java
java/org/apache/tomcat/util/threads/ResizableExecutor.java

index adfe9d4..13f4f81 100644 (file)
@@ -209,7 +209,19 @@ public abstract class AbstractEndpoint {
             }
         }
     }
-    public int getMaxThreads() { return maxThreads; }
+    public int getMaxThreads() {
+        if (running && executor!=null) {
+            if (executor instanceof java.util.concurrent.ThreadPoolExecutor) {
+                return ((java.util.concurrent.ThreadPoolExecutor)executor).getMaximumPoolSize();
+            } else if (executor instanceof ResizableExecutor) {
+                return ((ResizableExecutor)executor).getMaxThreads();
+            } else {
+                return -1;
+            }
+        } else {
+            return maxThreads;
+        }
+    }
 
     /**
      * Max keep alive requests 
index 3d137e3..2a411af 100644 (file)
@@ -25,6 +25,8 @@ public interface ResizableExecutor extends Executor {
      */
     public int getPoolSize();
     
+    public int getMaxThreads();
+
     /**
      * {@link java.util.concurrent.ThreadPoolExecutor#getActiveCount()}
      * @return {@link java.util.concurrent.ThreadPoolExecutor#getActiveCount()}