From: David ‘Bombe’ Roden Date: Sun, 28 Sep 2014 18:19:56 +0000 (+0200) Subject: Use an atomic boolean instead of a volatile boolean. X-Git-Tag: 0.9-rc1^2~3^2~93 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=5378059868b6681028a0e3dd3b58bff09fe8211a Use an atomic boolean instead of a volatile boolean. --- 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) {