From 2760a3e911f97ba940f378b4aacb40cd5ee30ebc Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Wed, 17 Jan 2024 22:51:05 -0500 Subject: [PATCH] ARTEMIS-4569 Improving order in which the list is added versus cancel call I just did some static analysis of this code, and I believe it would be better to first add to the list before setting the cancel task. Reason for that is in case the Runnable is dequeued between the add in the deQueue and setting the cancel task. Possibility is remote but my OCD wouldn't let me ignore this small possibility. --- .../activemq/artemis/core/paging/impl/PagingStoreImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java index 0fedf9a647..f21be1ccbd 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java @@ -1035,8 +1035,8 @@ public class PagingStoreImpl implements PagingStore { } private void addToBlockList(AtomicRunnable atomicRunnable, Consumer accepted) { - onMemoryFreedRunnables.add(atomicRunnable); atomicRunnable.setCancel(onMemoryFreedRunnables::remove); + onMemoryFreedRunnables.add(atomicRunnable); if (accepted != null) { accepted.accept(atomicRunnable); }