This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 267510

Summary: Possible race condition in ExplorerActionsImpl
Product: platform Reporter: rkeen
Component: ExplorerAssignee: Jan Peska <JPESKA>
Status: RESOLVED INCOMPLETE    
Severity: normal    
Priority: P3    
Version: 8.0.2   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:
Attachments: Possible solution

Description rkeen 2016-08-09 19:21:44 UTC
Created attachment 161607 [details]
Possible solution

ExplorerActionsImpl uses a background thread to determine the enabled state of its actions. The background thread calls ExplorerActionsImpl.BaseAction.toEnabled(boolean) to set the target state from the background thread and then queues up a call on the EventQueue to be run on the EDT to call ExplorerActionsImpl.BaseAction.syncEnable() which calls setEnabled if toEnable is non-null.

However, since the check for toEnable != null, the use of toEnable in the call to setEnabled, and the set of toEnable = null are all on separate lines there is the possibility that another call to toEnabled(boolean) will set toEnable after the call to setEnabled but before it is reset to null. The end result is that if the new value of toEnable was different from the one being acted upon, the action may end up in the wrong state.

One solution (patch attached) is to use an AtomicInteger to get the value of toEnable and set it to null (or NO_CHANGE) atomically, thus avoiding the race condition.

I don't have a reproducible case in the NetBeans IDE, but we encountered this in our custom application using the NetBeans platform. The attached patch solved the issue in our case.
Comment 1 rkeen 2018-12-26 21:53:31 UTC
Moved to the Apache issue tracking system: https://issues.apache.org/jira/browse/NETBEANS-1834