matthiasblaesing closed pull request #1058: [NETBEANS-1834] Fix possible race
condition enabling actions in explorer
URL: https://github.com/apache/incubator-netbeans/pull/1058
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/platform/openide.explorer/src/org/netbeans/modules/openide/explorer/ExplorerActionsImpl.java
b/platform/openide.explorer/src/org/netbeans/modules/openide/explorer/ExplorerActionsImpl.java
index bd26c7e79f..e48821cd5c 100644
---
a/platform/openide.explorer/src/org/netbeans/modules/openide/explorer/ExplorerActionsImpl.java
+++
b/platform/openide.explorer/src/org/netbeans/modules/openide/explorer/ExplorerActionsImpl.java
@@ -36,6 +36,7 @@
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.AbstractAction;
@@ -594,17 +595,21 @@ public Object getValue(String s) {
}
private static abstract class BaseAction extends AbstractAction {
- private volatile Boolean toEnable;
+ private static final int NO_CHANGE = 0;
+ private static final int ENABLED = 1;
+ private static final int DISABLED = 2;
+
+ private final AtomicInteger toEnable = new AtomicInteger(NO_CHANGE);
public void toEnabled(boolean e) {
- toEnable = e;
+ toEnable.set(e ? ENABLED : DISABLED);
}
public void syncEnable() {
assert EventQueue.isDispatchThread();
- if (toEnable != null) {
- setEnabled(toEnable);
- toEnable = null;
+ int toEnableValue = toEnable.getAndSet(NO_CHANGE);
+ if (toEnableValue != NO_CHANGE) {
+ setEnabled(toEnableValue == ENABLED);
}
}
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists