ensuring running test is right in Sweeper
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/49fc65c8 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/49fc65c8 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/49fc65c8 Branch: refs/heads/tomee-7.0.0-M1 Commit: 49fc65c85e3942dab74ebf67497dd1aad89ce43e Parents: 0515179 Author: Romain Manni-Bucau <rmannibu...@apache.org> Authored: Mon Jun 15 23:57:01 2015 +0200 Committer: Romain Manni-Bucau <rmannibu...@apache.org> Committed: Mon Jun 15 23:57:01 2015 +0200 ---------------------------------------------------------------------- .../openejb-core/src/main/java/org/apache/openejb/util/Pool.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/49fc65c8/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 949062c..73f5bbc 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 @@ -149,7 +149,9 @@ public class Pool<T> { public void stop() { final ScheduledFuture<?> future = this.future.get(); - if (future != null && !future.isDone() && !future.isCancelled() && !future.cancel(false)) { + if (future != null && this.future.compareAndSet(future, null) + && !future.isDone() && !future.isCancelled() + && !future.cancel(false)) { Logger.getLogger(Pool.class.getName()).log(Level.WARNING, "Pool scheduler task termination timeout expired"); }