From 4622066323e9ba5af0777d0c7315389ee8f647f5 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Wed, 15 Feb 2017 15:49:11 +0100 Subject: [PATCH] ARTEMIS-908: Replace lock by CAS to avoid deadlock --- .../artemis/core/paging/impl/PagingStoreImpl.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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 54992e464f..4e57c8520b 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 @@ -637,7 +637,7 @@ public class PagingStoreImpl implements PagingStore { // To be used when the memory is oversized either by local settings or global settings on blocking addresses private static final class OverSizedRunnable implements Runnable { - private boolean ran; + private final AtomicBoolean ran = new AtomicBoolean(false); private final Runnable runnable; @@ -646,11 +646,9 @@ public class PagingStoreImpl implements PagingStore { } @Override - public synchronized void run() { - if (!ran) { + public void run() { + if (ran.compareAndSet(false, true)) { runnable.run(); - - ran = true; } } }