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 - Possible race condition in ExplorerActionsImpl
Summary: Possible race condition in ExplorerActionsImpl
Status: RESOLVED INCOMPLETE
Alias: None
Product: platform
Classification: Unclassified
Component: Explorer (show other bugs)
Version: 8.0.2
Hardware: PC Linux
: P3 normal (vote)
Assignee: Jan Peska
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-09 19:21 UTC by rkeen
Modified: 2018-12-26 21:53 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Possible solution (1.61 KB, patch)
2016-08-09 19:21 UTC, rkeen
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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