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/437bbac8 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/437bbac8 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/437bbac8 Branch: refs/heads/tomee-1.7.x Commit: 437bbac8cf36e22f5d0d3922308a845b47019a8b Parents: e5ffc0c Author: Thiago Veronezi <[email protected]> Authored: Wed Jan 17 22:42:21 2018 -0500 Committer: Thiago Veronezi <[email protected]> Committed: Wed Jan 17 22:42:21 2018 -0500 ---------------------------------------------------------------------- .../core/instance/InstanceCreatorRunnable.java | 41 ------------- .../core/stateless/StatelessContainer.java | 3 +- .../stateless/StatelessInstanceManager.java | 60 ++++---------------- .../openejb/core/mdb/EndpointHandlerTest.java | 2 +- .../mdb/MaxSizePoolEndpointHandlerTest.java | 2 +- 5 files changed, 15 insertions(+), 93 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/437bbac8/container/openejb-core/src/main/java/org/apache/openejb/core/instance/InstanceCreatorRunnable.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/instance/InstanceCreatorRunnable.java b/container/openejb-core/src/main/java/org/apache/openejb/core/instance/InstanceCreatorRunnable.java deleted file mode 100644 index d87c330..0000000 --- a/container/openejb-core/src/main/java/org/apache/openejb/core/instance/InstanceCreatorRunnable.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openejb.core.instance; - -import org.apache.openejb.core.mdb.Instance; - -public final class InstanceCreatorRunnable implements Runnable { - - private final InstanceManagerData data; - private final InstanceManager.InstanceSupplier supplier; - private final long offset; - - public InstanceCreatorRunnable(final long maxAge, final long iteration, final long min, final double maxAgeOffset, - final InstanceManagerData data, final InstanceManager.InstanceSupplier supplier) { - this.data = data; - this.supplier = supplier; - this.offset = maxAge > 0 ? (long) (maxAge / maxAgeOffset * min * iteration) % maxAge : 0l; - } - - @Override - public void run() { - final Instance obj = supplier.create(); - if (obj != null) { - data.getPool().add(obj, offset); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tomee/blob/437bbac8/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContainer.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContainer.java b/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContainer.java index 5b4ee4a..7613c51 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContainer.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContainer.java @@ -29,7 +29,6 @@ import org.apache.openejb.core.Operation; import org.apache.openejb.core.ThreadContext; import org.apache.openejb.core.interceptor.InterceptorData; import org.apache.openejb.core.interceptor.InterceptorStack; -import org.apache.openejb.core.security.AbstractSecurityService; import org.apache.openejb.core.timer.EjbTimerService; import org.apache.openejb.core.transaction.TransactionPolicy; import org.apache.openejb.core.webservices.AddressingSupport; @@ -212,7 +211,7 @@ public class StatelessContainer implements org.apache.openejb.RpcContainer { @SuppressWarnings("ThrowFromFinallyBlock") private Object _invoke(final Method callMethod, final Method runMethod, final Object[] args, final Instance instance, final ThreadContext callContext, final InterfaceType type) - throws OpenEJBException { + throws OpenEJBException { final BeanContext beanContext = callContext.getBeanContext(); final TransactionPolicy txPolicy = createTransactionPolicy(beanContext.getTransactionType(callMethod, type), callContext); http://git-wip-us.apache.org/repos/asf/tomee/blob/437bbac8/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessInstanceManager.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessInstanceManager.java b/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessInstanceManager.java index 9d1ee5c..8d0b341 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessInstanceManager.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessInstanceManager.java @@ -63,15 +63,10 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.RejectedExecutionHandler; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import java.util.logging.Level; - -import static java.util.concurrent.TimeUnit.MILLISECONDS; public class StatelessInstanceManager { private static final Logger logger = Logger.getInstance(LogCategory.OPENEJB, "org.apache.openejb.util.resources"); @@ -92,20 +87,12 @@ public class StatelessInstanceManager { private final SecurityService securityService; private final Pool.Builder poolBuilder; private final ThreadPoolExecutor executor; - private final ScheduledExecutorService scheduledExecutor; - public StatelessInstanceManager(final SecurityService securityService, - final Duration accessTimeout, final Duration closeTimeout, - final Pool.Builder poolBuilder, final int callbackThreads, - final ScheduledExecutorService ses) { + public StatelessInstanceManager(final SecurityService securityService, final Duration accessTimeout, final Duration closeTimeout, final Pool.Builder poolBuilder, final int callbackThreads) { this.securityService = securityService; this.accessTimeout = accessTimeout; this.closeTimeout = closeTimeout; this.poolBuilder = poolBuilder; - this.scheduledExecutor = ses; - if (ScheduledThreadPoolExecutor.class.isInstance(ses) && !ScheduledThreadPoolExecutor.class.cast(ses).getRemoveOnCancelPolicy()) { - ScheduledThreadPoolExecutor.class.cast(ses).setRemoveOnCancelPolicy(true); - } if (accessTimeout.getUnit() == null) { accessTimeout.setUnit(TimeUnit.MILLISECONDS); @@ -114,8 +101,8 @@ public class StatelessInstanceManager { final int qsize = callbackThreads > 1 ? callbackThreads - 1 : 1; final ThreadFactory threadFactory = new DaemonThreadFactory("StatelessPool.worker."); this.executor = new ThreadPoolExecutor( - callbackThreads, callbackThreads * 2, - 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>(qsize), threadFactory); + callbackThreads, callbackThreads * 2, + 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>(qsize), threadFactory); this.executor.setRejectedExecutionHandler(new RejectedExecutionHandler() { @Override @@ -160,7 +147,7 @@ public class StatelessInstanceManager { final ThreadContext ctx = new ThreadContext(beanContext, null); final ThreadContext oldCallContext = ThreadContext.enter(ctx); try { - return createInstance(ctx, ctx.getBeanContext()); + return createInstance(ctx.getBeanContext()); } catch (final OpenEJBException e) { logger.error("Unable to fill pool: for deployment '" + beanContext.getDeploymentID() + "'", e); } finally { @@ -170,29 +157,6 @@ public class StatelessInstanceManager { } } - public void destroy() { - if (executor != null) { - executor.shutdown(); - try { - if (!executor.awaitTermination(10000, MILLISECONDS)) { - java.util.logging.Logger.getLogger(this.getClass().getName()).log(Level.WARNING, getClass().getSimpleName() + " pool timeout expired"); - } - } catch (final InterruptedException e) { - Thread.interrupted(); - } - } - if (scheduledExecutor != null) { - scheduledExecutor.shutdown(); - try { - if (!scheduledExecutor.awaitTermination(10000, MILLISECONDS)) { - java.util.logging.Logger.getLogger(this.getClass().getName()).log(Level.WARNING, getClass().getSimpleName() + " pool timeout expired"); - } - } catch (final InterruptedException e) { - Thread.interrupted(); - } - } - } - /** * Removes an instance from the pool and returns it for use * by the container in business methods. @@ -231,13 +195,13 @@ public class StatelessInstanceManager { } if (null == instance) { - instance = createInstance(callContext, beanContext); + instance = createInstance(beanContext); } - return instance; - } + return instance; + } - private Instance createInstance(final ThreadContext callContext, final BeanContext beanContext) throws ApplicationException { + private Instance createInstance(final BeanContext beanContext) throws ApplicationException { try { final InstanceContext context = beanContext.newInstance(); return new Instance(context.getBean(), context.getInterceptors(), context.getCreationalContext()); @@ -338,10 +302,10 @@ public class StatelessInstanceManager { final Options options = new Options(beanContext.getProperties()); final Duration accessTimeout = getDuration( - options, - "AccessTimeout", - getDuration(options, "Timeout", this.accessTimeout, TimeUnit.MILLISECONDS), // default timeout - TimeUnit.MILLISECONDS + options, + "AccessTimeout", + getDuration(options, "Timeout", this.accessTimeout, TimeUnit.MILLISECONDS), // default timeout + TimeUnit.MILLISECONDS ); final Duration closeTimeout = getDuration(options, "CloseTimeout", this.closeTimeout, TimeUnit.MINUTES); http://git-wip-us.apache.org/repos/asf/tomee/blob/437bbac8/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/EndpointHandlerTest.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/EndpointHandlerTest.java b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/EndpointHandlerTest.java index d401baa..be0a4d4 100644 --- a/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/EndpointHandlerTest.java +++ b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/EndpointHandlerTest.java @@ -120,7 +120,7 @@ public class EndpointHandlerTest { }) public static class Listener implements InboundListener { public static CountDownLatch latch; - private static final List<Boolean> BOOLEANS = new CopyOnWriteArrayList<>(); + private static final List<Boolean> BOOLEANS = new CopyOnWriteArrayList<Boolean>(); static final AtomicLong COUNTER = new AtomicLong(); http://git-wip-us.apache.org/repos/asf/tomee/blob/437bbac8/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/MaxSizePoolEndpointHandlerTest.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/MaxSizePoolEndpointHandlerTest.java b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/MaxSizePoolEndpointHandlerTest.java index af50393..89f1387 100644 --- a/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/MaxSizePoolEndpointHandlerTest.java +++ b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/MaxSizePoolEndpointHandlerTest.java @@ -121,7 +121,7 @@ public class MaxSizePoolEndpointHandlerTest { }) public static class Listener implements InboundListener { public static CountDownLatch latch; - private static final List<Boolean> BOOLEANS = new CopyOnWriteArrayList<>(); + private static final List<Boolean> BOOLEANS = new CopyOnWriteArrayList<Boolean>(); static final AtomicLong COUNTER = new AtomicLong();
