From 5378059868b6681028a0e3dd3b58bff09fe8211a Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 28 Sep 2014 20:19:56 +0200 Subject: [PATCH] Use an atomic boolean instead of a volatile boolean. --- src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java b/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java index 551dc4f..e49537b 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java +++ b/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java @@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Level; import java.util.logging.Logger; @@ -74,7 +75,7 @@ public class FcpInterface { private static final Logger logger = Logging.getLogger(FcpInterface.class); /** Whether the FCP interface is currently active. */ - private volatile boolean active; + private final AtomicBoolean active = new AtomicBoolean(); /** What function full access is required for. */ private volatile FullAccessRequired fullAccessRequired = FullAccessRequired.ALWAYS; @@ -113,7 +114,7 @@ public class FcpInterface { @VisibleForTesting boolean isActive() { - return active; + return active.get(); } /** @@ -125,7 +126,7 @@ public class FcpInterface { * deactivate the FCP interface */ public void setActive(boolean active) { - this.active = active; + this.active.set(active); } @VisibleForTesting @@ -162,7 +163,7 @@ public class FcpInterface { * {@link FredPluginFCP#ACCESS_FCP_RESTRICTED} */ public void handle(PluginReplySender pluginReplySender, SimpleFieldSet parameters, Bucket data, int accessType) { - if (!active) { + if (!active.get()) { try { sendReply(pluginReplySender, null, new ErrorResponse(400, "FCP Interface deactivated")); } catch (PluginNotFoundException pnfe1) { -- 2.7.4