Bug 575486 - AutoBuildJob booleans need volatile modifier
forceBuild & buildNeeded were accessed from not synchronized methods -
should be made volatile to avoid stale content seen by other threads.
... And to be consistent, set all boolean flags to volatile, just in
case there will be new code reading them from non synchnronized methods.
Change-Id: I2eb1fa57d7e3ca0e65986f598297a97a7e432291
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.resources/+/184205
Reviewed-by: Jörg Kubitz <jkubitz-eclipse@gmx.de>
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/AutoBuildJob.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/AutoBuildJob.java
index 55452e4..b9ad233 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/AutoBuildJob.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/AutoBuildJob.java
@@ -30,16 +30,16 @@
* of whether autobuild is on or off.
*/
class AutoBuildJob extends Job implements Preferences.IPropertyChangeListener {
- private boolean avoidBuild = false;
- private boolean buildNeeded = false;
- private boolean forceBuild = false;
+ private volatile boolean avoidBuild;
+ private volatile boolean buildNeeded;
+ private volatile boolean forceBuild;
/**
* Indicates that another thread tried to modify the workspace during
* the autobuild. The autobuild should be immediately rescheduled
* so that it will run as soon as the next workspace modification completes.
*/
- private boolean interrupted = false;
- private boolean isAutoBuilding = false;
+ private volatile boolean interrupted;
+ private volatile boolean isAutoBuilding;
private volatile long lastBuild = 0L;
private Preferences preferences = ResourcesPlugin.getPlugin().getPluginPreferences();
private final Bundle systemBundle = Platform.getBundle("org.eclipse.osgi"); //$NON-NLS-1$