diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/Instance.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/Instance.java index 12636456fa9..1dd441aaaf4 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/Instance.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/Instance.java @@ -82,15 +82,19 @@ protected void afterExecute(Runnable t, Throwable e) { private final ThreadObserverHelper _observerHelper; } + // The thead pool executor uses an unbounded queue. The tasks would wait in the queue until a + // core pool thread is available to run it and the value of the maximumPoolSize therefore + // doesn't have any effect. private static class QueueExecutor extends java.util.concurrent.ThreadPoolExecutor { QueueExecutor(Properties props, String threadName) { super( - 1, - 1, - 0, + 10, + 10, + 1000, TimeUnit.MILLISECONDS, new java.util.concurrent.LinkedBlockingQueue(), Util.createThreadFactory(props, threadName)); + allowCoreThreadTimeOut(true); _observerHelper = new ThreadObserverHelper(threadName); } diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/QueueExecutorService.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/QueueExecutorService.java index d0588c3dc6d..0a85ec7ed32 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/QueueExecutorService.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/QueueExecutorService.java @@ -13,14 +13,6 @@ final class QueueExecutorService { QueueExecutorService(ExecutorService executor) { _executor = executor; - _thread = - executeNoThrow( - new Callable() { - @Override - public Thread call() { - return Thread.currentThread(); - } - }); } public T executeNoThrow(Callable callable) { @@ -33,19 +25,6 @@ public T executeNoThrow(Callable callable) { } public T execute(Callable callable) throws RetryException { - if (_thread == Thread.currentThread()) { - try { - return callable.call(); - } catch (RuntimeException ex) { - throw ex; - } catch (Exception ex) { - // RetryException is the only checked exception that - // can be raised by Ice internals. - assert (ex instanceof RetryException); - throw (RetryException) ex; - } - } - boolean interrupted = false; try { Future future = _executor.submit(callable); @@ -78,5 +57,4 @@ public T execute(Callable callable) throws RetryException { } final ExecutorService _executor; - final Thread _thread; }