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.
This commit is contained in:
Clebert Suconic 2024-01-17 22:51:05 -05:00
parent 22a31fb254
commit 2760a3e911
1 changed files with 1 additions and 1 deletions

View File

@ -1035,8 +1035,8 @@ public class PagingStoreImpl implements PagingStore {
}
private void addToBlockList(AtomicRunnable atomicRunnable, Consumer<AtomicRunnable> accepted) {
onMemoryFreedRunnables.add(atomicRunnable);
atomicRunnable.setCancel(onMemoryFreedRunnables::remove);
onMemoryFreedRunnables.add(atomicRunnable);
if (accepted != null) {
accepted.accept(atomicRunnable);
}