diff options
author | Andrey Loskutov | 2016-11-29 15:30:21 +0000 |
---|---|---|
committer | Thomas Watson | 2016-11-29 18:28:37 +0000 |
commit | 1d3b01d9c5aed305b8280d281dc165f1b3cd0cb1 (patch) | |
tree | ab822584feb1edb36ed2ffd84badad475e332858 | |
parent | 1a0a0068fc8c3997f73bea9d60f7365855291435 (diff) | |
download | rt.equinox.bundles-1d3b01d9c5aed305b8280d281dc165f1b3cd0cb1.tar.gz rt.equinox.bundles-1d3b01d9c5aed305b8280d281dc165f1b3cd0cb1.tar.xz rt.equinox.bundles-1d3b01d9c5aed305b8280d281dc165f1b3cd0cb1.zip |
Bug 507092 - Eclipse fails to start: "An internal error occurred during:Y20161229-1000Y20161223-1030Y20161222-1000Y20161215-1200Y20161208-1000Y20161201-1000S4_7_0_M4I20170102-2000I20170101-2000I20161231-2000I20161230-2000I20161229-2000I20161228-2000I20161227-2000I20161226-2000I20161225-2000I20161224-2000I20161223-2000I20161223-0615I20161222-2000I20161221-2000I20161221-0400I20161220-2000I20161220-0530I20161219-2000I20161219-0145I20161218-2000I20161217-2000I20161216-2000I20161215-2000I20161215-0915I20161215-0830I20161215-0730I20161215-0130I20161214-2000I20161214-1005I20161213-2000I20161213-0600I20161213-0300I20161212-2000I20161211-2000I20161210-2000I20161208-0830I20161208-0730I20161207-2000I20161207-1340I20161207-0800I20161207-0515I20161206-2000I20161206-0800I20161205-2000I20161205-0800I20161204-2000I20161203-2000I20161202-2000I20161201-2000I20161201-0800I20161130-2000I20161129-2330I20161129-2000
"Initializing workspace."
Fixes multiple possible race conditions during initialization of
instance location uncovered by the change in ResourcesPlugin
initialization via commit 8d90fb030df310a974aae5d27d0bc2610c1a14ad.
The original issue from bug 507092 is fixed in
Activator.getInstanceLocation(), see 507092 comment 27. The change in
MetaDataKeeper makes sure every thread uses same DataArea instance, and
the change in DataArea.assertLocationInitialized() makes sure the
critical file I/O operations on the metadata folder aren't executed in
parallel by multiple threads.
Change-Id: I4ce3ec522b9ef1be41143d52dc440668a958fbcd
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
3 files changed, 26 insertions, 59 deletions
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java index 5b62860d2..e872f8acc 100644 --- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java +++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java @@ -68,6 +68,15 @@ public class Activator implements BundleActivator { public void start(BundleContext context) throws Exception { bundleContext = context; singleton = this; + + installLocationTracker = openServiceTracker(Location.INSTALL_FILTER); + instanceLocationTracker = openServiceTracker(Location.INSTANCE_FILTER); + configLocationTracker = openServiceTracker(Location.CONFIGURATION_FILTER); + bundleTracker = openServiceTracker(PackageAdmin.class); + debugTracker = openServiceTracker(DebugOptions.class); + logTracker = openServiceTracker(FrameworkLog.class); + localizationTracker = openServiceTracker(BundleLocalization.class); + RuntimeLog.setLogWriter(getPlatformWriter(context)); Dictionary<String, Object> urlProperties = new Hashtable<>(); urlProperties.put("protocol", "platform"); //$NON-NLS-1$ //$NON-NLS-2$ @@ -99,16 +108,6 @@ public class Activator implements BundleActivator { * Return the configuration location service, if available. */ public Location getConfigurationLocation() { - if (configLocationTracker == null) { - Filter filter = null; - try { - filter = bundleContext.createFilter(Location.CONFIGURATION_FILTER); - } catch (InvalidSyntaxException e) { - // should not happen - } - configLocationTracker = new ServiceTracker<>(bundleContext, filter, null); - configLocationTracker.open(); - } return configLocationTracker.getService(); } @@ -116,10 +115,6 @@ public class Activator implements BundleActivator { * Return the debug options service, if available. */ public DebugOptions getDebugOptions() { - if (debugTracker == null) { - debugTracker = new ServiceTracker<>(bundleContext, DebugOptions.class.getName(), null); - debugTracker.open(); - } return debugTracker.getService(); } @@ -127,10 +122,6 @@ public class Activator implements BundleActivator { * Return the framework log service, if available. */ public FrameworkLog getFrameworkLog() { - if (logTracker == null) { - logTracker = new ServiceTracker<>(bundleContext, FrameworkLog.class.getName(), null); - logTracker.open(); - } return logTracker.getService(); } @@ -138,16 +129,6 @@ public class Activator implements BundleActivator { * Return the instance location service, if available. */ public Location getInstanceLocation() { - if (instanceLocationTracker == null) { - Filter filter = null; - try { - filter = bundleContext.createFilter(Location.INSTANCE_FILTER); - } catch (InvalidSyntaxException e) { - // ignore this. It should never happen as we have tested the above format. - } - instanceLocationTracker = new ServiceTracker<>(bundleContext, filter, null); - instanceLocationTracker.open(); - } return instanceLocationTracker.getService(); } @@ -176,10 +157,6 @@ public class Activator implements BundleActivator { * Return the package admin service, if available. */ private PackageAdmin getBundleAdmin() { - if (bundleTracker == null) { - bundleTracker = new ServiceTracker<>(getContext(), PackageAdmin.class.getName(), null); - bundleTracker.open(); - } return bundleTracker.getService(); } @@ -197,19 +174,22 @@ public class Activator implements BundleActivator { * Return the install location service if available. */ public Location getInstallLocation() { - if (installLocationTracker == null) { - Filter filter = null; - try { - filter = bundleContext.createFilter(Location.INSTALL_FILTER); - } catch (InvalidSyntaxException e) { - // should not happen - } - installLocationTracker = new ServiceTracker<>(bundleContext, filter, null); - installLocationTracker.open(); - } return installLocationTracker.getService(); } + private <T> ServiceTracker<Object, T> openServiceTracker(String filterString) throws InvalidSyntaxException { + Filter filter = bundleContext.createFilter(filterString); + ServiceTracker<Object, T> tracker = new ServiceTracker<>(bundleContext, filter, null); + tracker.open(); + return tracker; + } + + private <T> ServiceTracker<Object, T> openServiceTracker(Class<?> clazz) { + ServiceTracker<Object, T> tracker = new ServiceTracker<>(bundleContext, clazz.getName(), null); + tracker.open(); + return tracker; + } + /** * Returns the bundle id of the bundle that contains the provided object, or * <code>null</code> if the bundle could not be determined. @@ -233,12 +213,7 @@ public class Activator implements BundleActivator { */ public ResourceBundle getLocalization(Bundle bundle, String locale) throws MissingResourceException { if (localizationTracker == null) { - BundleContext context = Activator.getContext(); - if (context == null) { - throw new MissingResourceException(CommonMessages.activator_resourceBundleNotStarted, bundle.getSymbolicName(), ""); //$NON-NLS-1$ - } - localizationTracker = new ServiceTracker<>(context, BundleLocalization.class.getName(), null); - localizationTracker.open(); + throw new MissingResourceException(CommonMessages.activator_resourceBundleNotStarted, bundle.getSymbolicName(), ""); //$NON-NLS-1$ } BundleLocalization location = localizationTracker.getService(); ResourceBundle result = null; @@ -262,31 +237,24 @@ public class Activator implements BundleActivator { } if (installLocationTracker != null) { installLocationTracker.close(); - installLocationTracker = null; } if (configLocationTracker != null) { configLocationTracker.close(); - configLocationTracker = null; } if (bundleTracker != null) { bundleTracker.close(); - bundleTracker = null; } if (debugTracker != null) { debugTracker.close(); - debugTracker = null; } if (logTracker != null) { logTracker.close(); - logTracker = null; } if (instanceLocationTracker != null) { instanceLocationTracker.close(); - instanceLocationTracker = null; } if (localizationTracker != null) { localizationTracker.close(); - localizationTracker = null; } if (debugRegistration != null) { debugRegistration.unregister(); diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DataArea.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DataArea.java index 66d9feee7..3db52a1bc 100644 --- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DataArea.java +++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DataArea.java @@ -39,7 +39,7 @@ public class DataArea { private IPath location; //The location of the instance data private boolean initialized = false; - protected void assertLocationInitialized() throws IllegalStateException { + protected synchronized void assertLocationInitialized() throws IllegalStateException { if (location != null && initialized) return; Activator activator = Activator.getDefault(); diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/MetaDataKeeper.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/MetaDataKeeper.java index dac414a4c..db99ba001 100644 --- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/MetaDataKeeper.java +++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/MetaDataKeeper.java @@ -10,8 +10,6 @@ *******************************************************************************/ package org.eclipse.core.internal.runtime; -import org.eclipse.core.internal.runtime.DataArea; - /** * The class contains a set of utilities working platform metadata area. * This class can only be used if OSGi plugin is available. @@ -26,8 +24,9 @@ public class MetaDataKeeper { /** * Returns the object which defines the location and organization * of the platform's meta area. + * @return non null */ - public static DataArea getMetaArea() { + public static synchronized DataArea getMetaArea() { if (metaArea != null) return metaArea; |