Bug 576736 - avoid parallel baseline initialization
With multiple jobs running in parallel, baseline could be initialized in
parallel and threads may see partly initialized baselines too. That
should be avoided.
Change-Id: Idb0d99e1071e957edd86bfb17480d62fc0a6baf1
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Reviewed-on: https://git.eclipse.org/r/c/pde/eclipse.pde.ui/+/189559
Tested-by: PDE Bot <pde-bot@eclipse.org>
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ApiBaseline.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ApiBaseline.java
index 5292f8d..54cb0ea 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ApiBaseline.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ApiBaseline.java
@@ -139,7 +139,7 @@
* Map of <code>componentId -> {@link IApiComponent}</code>
* </p>
*/
- private HashMap<String, IApiComponent> fComponentsById = null;
+ private volatile Map<String, IApiComponent> fComponentsById;
/**
* Maps component id's to all components sorted from higher to lower version.
*/
@@ -731,7 +731,7 @@
* Loads the information from the *.profile file the first time the baseline
* is accessed
*/
- private void loadBaselineInfos() {
+ private synchronized void loadBaselineInfos() {
if (fComponentsById != null) {
return;
}