This commit is contained in:
Francesco Nigro 2019-06-20 16:28:46 +02:00
commit 7e6efb26e2
2 changed files with 5 additions and 2 deletions

View File

@ -196,8 +196,11 @@ public class AMQPConnectionContext extends ProtonInitializable implements EventH
if (scheduledPool != null && scheduledPool instanceof ThreadPoolExecutor && if (scheduledPool != null && scheduledPool instanceof ThreadPoolExecutor &&
scheduledFuture != null && scheduledFuture instanceof Runnable) { scheduledFuture != null && scheduledFuture instanceof Runnable) {
if (!((ThreadPoolExecutor) scheduledPool).remove((Runnable) scheduledFuture)) { if (!((ThreadPoolExecutor) scheduledPool).remove((Runnable) scheduledFuture) &&
!scheduledFuture.isCancelled() && !scheduledFuture.isDone()) {
log.warn("Scheduled task can't be removed from scheduledPool."); log.warn("Scheduled task can't be removed from scheduledPool.");
} else {
scheduledFuture = null;
} }
} }
} }

View File

@ -81,6 +81,6 @@ public class AMQPConnectionContextTest {
connectionContext.close(null); connectionContext.close(null);
Assert.assertEquals(0, scheduledPool.getTaskCount()); Assert.assertEquals(0, scheduledPool.getQueue().size());
} }
} }