fix conflicts backport from tomee 7.0.x
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/e5c5f9d4 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/e5c5f9d4 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/e5c5f9d4 Branch: refs/heads/tomee-1.7.x Commit: e5c5f9d410bc48432b59b46684c97219083b2531 Parents: 94fa39e Author: Thiago Veronezi <[email protected]> Authored: Wed Jan 17 13:30:07 2018 -0500 Committer: Thiago Veronezi <[email protected]> Committed: Wed Jan 17 13:30:07 2018 -0500 ---------------------------------------------------------------------- .../src/main/java/org/apache/openejb/util/Pool.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/e5c5f9d4/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 08c87b7..33617e1 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 @@ -526,7 +526,7 @@ public class Pool<T> { } private static long now() { - return TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS); + return MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS); } public final class Entry { @@ -765,7 +765,7 @@ public class Pool<T> { final long idle = now - entry.used; if (idleTimeout > 0 && idle > idleTimeout) { - // too lazy -- timed out + // too lazy -- timed out final Expired expired = new Expired(entry, Event.IDLE); expiredList.add(expired); @@ -1120,6 +1120,7 @@ public class Pool<T> { private Duration interval = new Duration(5 * 60, SECONDS); private Supplier<T> supplier; private Executor executor; + private ScheduledExecutorService scheduledExecutorService; private boolean replaceAged; private boolean replaceFlushed; private boolean garbageCollection = true; @@ -1231,9 +1232,18 @@ public class Pool<T> { this.executor = executor; } + public void setScheduledExecutor(final ScheduledExecutorService scheduledExecutorService) { + this.scheduledExecutorService = scheduledExecutorService; + } + + @SuppressWarnings("unchecked") public Pool<T> build() { //noinspection unchecked - return new Pool(max, min, strict, maxAge.getTime(MILLISECONDS), idleTimeout.getTime(MILLISECONDS), interval.getTime(MILLISECONDS), executor, supplier, replaceAged, maxAgeOffset, this.garbageCollection, replaceFlushed); + final Pool pool = new Pool(max, min, strict, maxAge.getTime(MILLISECONDS), idleTimeout.getTime(MILLISECONDS), interval.getTime(MILLISECONDS), executor, supplier, replaceAged, maxAgeOffset, this.garbageCollection, replaceFlushed); + if (scheduledExecutorService != null) { + pool.scheduler.set(scheduledExecutorService); + } + return pool; } }
