michaelandrepearce commented on a change in pull request #2727: ARTEMIS-2394 
Improve scheduling sync for AMQPConnectionContext
URL: https://github.com/apache/activemq-artemis/pull/2727#discussion_r303683263
 
 

 ##########
 File path: 
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java
 ##########
 @@ -191,17 +190,13 @@ public void flush() {
    }
 
    public void close(ErrorCondition errorCondition) {
-      synchronized (schedulingLock) {
-         isSchedulingCancelled = true;
-
-         if (scheduledPool != null && scheduledPool instanceof 
ThreadPoolExecutor &&
-            scheduledFuture != null && scheduledFuture instanceof Runnable) {
-            if (!((ThreadPoolExecutor) scheduledPool).remove((Runnable) 
scheduledFuture) &&
-               !scheduledFuture.isCancelled() && !scheduledFuture.isDone()) {
-               log.warn("Scheduled task can't be removed from scheduledPool.");
-            } else {
-               scheduledFuture = null;
-            }
+      Future scheduledFuture = scheduledFutureRef.getAndSet(null);
+
+      if (scheduledPool != null && scheduledPool instanceof ThreadPoolExecutor 
&&
+         scheduledFuture != null && scheduledFuture != voidFuture && 
scheduledFuture instanceof Runnable) {
 
 Review comment:
   scheduledFuture != null is redundent, due to scheduledFuture instanceOf 
runnable check.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to