Repository: tomee
Updated Branches:
  refs/heads/master 7f63e5e46 -> 55d6d5ec8


avoid to stop twice the thread pool but ensure it runs - assume it was the issue


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/55d6d5ec
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/55d6d5ec
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/55d6d5ec

Branch: refs/heads/master
Commit: 55d6d5ec89da68a6794487bc75f95b55cad7b483
Parents: 7f63e5e
Author: rmannibucau <[email protected]>
Authored: Fri Mar 3 22:43:42 2017 +0100
Committer: rmannibucau <[email protected]>
Committed: Fri Mar 3 22:43:42 2017 +0100

----------------------------------------------------------------------
 .../main/java/org/apache/openejb/util/Pool.java | 47 ++++++++------------
 1 file changed, 19 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/55d6d5ec/container/openejb-core/src/main/java/org/apache/openejb/util/Pool.java
----------------------------------------------------------------------
diff --git 
a/container/openejb-core/src/main/java/org/apache/openejb/util/Pool.java 
b/container/openejb-core/src/main/java/org/apache/openejb/util/Pool.java
index b2bc9b2..299f841 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/util/Pool.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/util/Pool.java
@@ -469,38 +469,29 @@ public class Pool<T> {
 
         final ScheduledExecutorService ses = this.scheduler.getAndSet(null);
 
-        if (null != ses) {
-            try {
-                ses.shutdown();
-                if(!ses.awaitTermination(timeout, unit)){
-                    Logger.getLogger(Pool.class.getName()).log(Level.WARNING, 
"Pool scheduler termination timeout expired");
-                }
-            } catch (final Exception e) {
-                //no-op
+        try {
+            // drain all keys so no new instances will be accepted into the 
pool
+            while (instances.tryAcquire()) {
+                Thread.yield();
             }
-        }
-
-        // drain all keys so no new instances will be accepted into the pool
-        while (instances.tryAcquire()) {
-            Thread.yield();
-        }
-        while (minimum.tryAcquire()) {
-            Thread.yield();
-        }
-        instances.drainPermits();
-        minimum.drainPermits();
+            while (minimum.tryAcquire()) {
+                Thread.yield();
+            }
+            instances.drainPermits();
+            minimum.drainPermits();
 
-        // flush and sweep
-        flush();
-        try {
-            sweeper.run();
-        } catch (final RejectedExecutionException e) {
-            //Ignore
+            // flush and sweep
+            flush();
+            try {
+                sweeper.run();
+            } catch (final RejectedExecutionException e) {
+                //Ignore
+            }
+        } finally {
+            // Stop the sweeper thread
+            stop();
         }
 
-        // Stop the sweeper thread
-        stop();
-
         // Drain all leases
         if (!(available instanceof Overdraft)) {
             while (available.tryAcquire()) {

Reply via email to