Repository: tomee
Updated Branches:
  refs/heads/master 9fa28a270 -> 9b7b46570


Terminate scheduler on close


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

Branch: refs/heads/master
Commit: 7f63e5e46851835671363eff0f472bc5ed097518
Parents: 9fa28a2
Author: AndyGee <[email protected]>
Authored: Fri Mar 3 18:19:00 2017 +0100
Committer: AndyGee <[email protected]>
Committed: Fri Mar 3 18:19:00 2017 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/openejb/util/Pool.java    | 13 +++++++++++++
 1 file changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/7f63e5e4/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 07ff896..b2bc9b2 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
@@ -467,6 +467,19 @@ public class Pool<T> {
 
     public boolean close(final long timeout, final TimeUnit unit) throws 
InterruptedException {
 
+        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
+            }
+        }
+
         // drain all keys so no new instances will be accepted into the pool
         while (instances.tryAcquire()) {
             Thread.yield();

Reply via email to