Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 127094 Details for
Bug 266205
IllegalStateException while saving preferences
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Fix
patch.txt (text/plain), 12.31 KB, created by
John Arthorne
on 2009-02-28 15:43:02 EST
(
hide
)
Description:
Fix
Filename:
MIME Type:
Creator:
John Arthorne
Created:
2009-02-28 15:43:02 EST
Size:
12.31 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.equinox.p2.engine >Index: src/org/eclipse/equinox/internal/p2/engine/EngineActivator.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/EngineActivator.java,v >retrieving revision 1.6 >diff -u -r1.6 EngineActivator.java >--- src/org/eclipse/equinox/internal/p2/engine/EngineActivator.java 13 Feb 2008 22:49:01 -0000 1.6 >+++ src/org/eclipse/equinox/internal/p2/engine/EngineActivator.java 28 Feb 2009 20:39:59 -0000 >@@ -10,6 +10,7 @@ > *******************************************************************************/ > package org.eclipse.equinox.internal.p2.engine; > >+import org.eclipse.core.runtime.jobs.Job; > import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus; > import org.eclipse.equinox.internal.provisional.p2.engine.Engine; > import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; >@@ -58,6 +59,8 @@ > public void stop(BundleContext aContext) throws Exception { > tracker.close(); > tracker = null; >+ //ensure there are no more profile preference save jobs running >+ Job.getJobManager().join(ProfilePreferences.PROFILE_SAVE_JOB_FAMILY, null); > > EngineActivator.context = null; > } >Index: src/org/eclipse/equinox/internal/p2/engine/messages.properties >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/messages.properties,v >retrieving revision 1.19 >diff -u -r1.19 messages.properties >--- src/org/eclipse/equinox/internal/p2/engine/messages.properties 27 Feb 2009 15:47:20 -0000 1.19 >+++ src/org/eclipse/equinox/internal/p2/engine/messages.properties 28 Feb 2009 20:39:59 -0000 >@@ -49,6 +49,7 @@ > shared_profile_not_found=Shared profile {0} not found. > > ProfilePreferences_save_failed=An error occurred while saving preferences for profile {0} >+ProfilePreferences_saving=Saving profile preferences > ProfilePreferences_load_failed=An error occurred while loading preferences for profile {0} > ProfilePreferences_nullDir=Profile data directory is unexpectedly null > ProfilePreferences_Profile_not_found=Requested profile {0} not located for preferences. >\ No newline at end of file >Index: src/org/eclipse/equinox/internal/p2/engine/ProfilePreferences.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfilePreferences.java,v >retrieving revision 1.4 >diff -u -r1.4 ProfilePreferences.java >--- src/org/eclipse/equinox/internal/p2/engine/ProfilePreferences.java 27 Feb 2009 15:47:20 -0000 1.4 >+++ src/org/eclipse/equinox/internal/p2/engine/ProfilePreferences.java 28 Feb 2009 20:39:59 -0000 >@@ -14,14 +14,45 @@ > import java.util.*; > import org.eclipse.core.internal.preferences.EclipsePreferences; > import org.eclipse.core.runtime.*; >+import org.eclipse.core.runtime.jobs.Job; > import org.eclipse.core.runtime.preferences.IEclipsePreferences; > import org.eclipse.equinox.internal.p2.core.helpers.*; > import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; > import org.eclipse.equinox.internal.provisional.p2.engine.*; > import org.eclipse.osgi.util.NLS; >+import org.osgi.framework.Bundle; >+import org.osgi.framework.BundleContext; > import org.osgi.service.prefs.BackingStoreException; > >+/** >+ * A preference implementation that stores preferences in the engine's profile >+ * data area. There is one preference file per profile, with an additional file >+ * that is used when there is no currently running profile. >+ */ > public class ProfilePreferences extends EclipsePreferences { >+ private static final long SAVE_SCHEDULE_DELAY = 500; >+ public static final Object PROFILE_SAVE_JOB_FAMILY = new Object(); >+ >+ private class SaveJob extends Job { >+ SaveJob() { >+ super(Messages.ProfilePreferences_saving); >+ setSystem(true); >+ } >+ >+ protected IStatus run(IProgressMonitor monitor) { >+ try { >+ doSave(); >+ } catch (BackingStoreException e) { >+ LogHelper.log(new Status(IStatus.WARNING, EngineActivator.ID, "Exception saving profile preferences", e)); //$NON-NLS-1$ >+ } >+ return Status.OK_STATUS; >+ } >+ >+ public boolean belongsTo(Object family) { >+ return family == PROFILE_SAVE_JOB_FAMILY; >+ } >+ } >+ > private int segmentCount; > private String qualifier; > //private IPath location; >@@ -30,6 +61,7 @@ > private static Set loadedNodes = new HashSet(); > > private Object profileLock; >+ private SaveJob saveJob; > > public ProfilePreferences() { > this(null, null); >@@ -150,11 +182,30 @@ > return URLUtil.toFile(location.getDataArea(EngineActivator.ID)); > } > >+ /** >+ * Schedules the save job. This method is synchronized to protect lazily initialization >+ * of the save job instance. >+ */ >+ protected synchronized void save() { >+ if (saveJob == null) >+ saveJob = new SaveJob(); >+ //only schedule a save if the engine bundle is still running >+ BundleContext context = EngineActivator.getContext(); >+ if (context == null) >+ return; >+ try { >+ if (context.getBundle().getState() == Bundle.ACTIVE) >+ saveJob.schedule(SAVE_SCHEDULE_DELAY); >+ } catch (IllegalStateException e) { >+ //bundle has been stopped concurrently, so don't save >+ } >+ } >+ > /* > * (non-Javadoc) > * Create an Engine phase to save profile preferences > */ >- protected void save() throws BackingStoreException { >+ protected void doSave() throws BackingStoreException { > synchronized (((ProfilePreferences) parent).profileLock) { > String profileId = getSegment(absolutePath(), 1); > IProfile profile = computeProfile(profileId); >Index: src/org/eclipse/equinox/internal/p2/engine/Messages.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Messages.java,v >retrieving revision 1.17 >diff -u -r1.17 Messages.java >--- src/org/eclipse/equinox/internal/p2/engine/Messages.java 27 Feb 2009 15:47:20 -0000 1.17 >+++ src/org/eclipse/equinox/internal/p2/engine/Messages.java 28 Feb 2009 20:39:59 -0000 >@@ -39,6 +39,8 @@ > public static String Profile_Parent_Not_Found; > > public static String ProfilePreferences_save_failed; >+ >+ public static String ProfilePreferences_saving; > public static String ProfilePreferences_load_failed; > > public static String ProfilePreferences_nullDir; >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF,v >retrieving revision 1.27 >diff -u -r1.27 MANIFEST.MF >--- META-INF/MANIFEST.MF 20 Feb 2009 22:44:00 -0000 1.27 >+++ META-INF/MANIFEST.MF 28 Feb 2009 20:39:59 -0000 >@@ -59,4 +59,5 @@ > Require-Bundle: org.eclipse.equinox.common, > org.eclipse.equinox.registry, > org.eclipse.osgi, >- org.eclipse.equinox.p2.metadata.repository;bundle-version="1.0.100" >+ org.eclipse.equinox.p2.metadata.repository;bundle-version="1.0.100", >+ org.eclipse.core.jobs;bundle-version="[3.4.0,4.0.0)" >#P org.eclipse.equinox.p2.tests >Index: src/org/eclipse/equinox/p2/tests/engine/ProfilePreferencesTest.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfilePreferencesTest.java,v >retrieving revision 1.3 >diff -u -r1.3 ProfilePreferencesTest.java >--- src/org/eclipse/equinox/p2/tests/engine/ProfilePreferencesTest.java 27 Feb 2009 15:47:21 -0000 1.3 >+++ src/org/eclipse/equinox/p2/tests/engine/ProfilePreferencesTest.java 28 Feb 2009 20:40:00 -0000 >@@ -10,8 +10,10 @@ > *******************************************************************************/ > package org.eclipse.equinox.p2.tests.engine; > >+import org.eclipse.core.runtime.jobs.Job; > import org.eclipse.core.runtime.preferences.IPreferencesService; > import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; >+import org.eclipse.equinox.internal.p2.engine.ProfilePreferences; > import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; > import org.eclipse.equinox.p2.tests.TestActivator; > import org.osgi.service.prefs.BackingStoreException; >@@ -58,13 +60,26 @@ > } catch (BackingStoreException e) { > fail("Unable to write to preferences: " + e.getMessage()); > } >+ waitForSave(); > > try { > pref.parent().removeNode(); > } catch (BackingStoreException e) { > // > } >+ waitForSave(); > pref = prefServ.getRootNode().node("/profile/_SELF_/testing"); >- assertTrue("Value not present after load", value.equals(pref.get(key, null))); >+ assertEquals("Value not present after load", value, pref.get(key, null)); >+ } >+ >+ /** >+ * Wait for preferences to be flushed to disk >+ */ >+ private void waitForSave() { >+ try { >+ Job.getJobManager().join(ProfilePreferences.PROFILE_SAVE_JOB_FAMILY, null); >+ } catch (InterruptedException e) { >+ fail("4.99", e); >+ } > } > } >#P org.eclipse.equinox.p2.core >Index: src/org/eclipse/equinox/internal/p2/core/helpers/AbstractRepositoryManager.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/AbstractRepositoryManager.java,v >retrieving revision 1.21 >diff -u -r1.21 AbstractRepositoryManager.java >--- src/org/eclipse/equinox/internal/p2/core/helpers/AbstractRepositoryManager.java 26 Feb 2009 21:55:24 -0000 1.21 >+++ src/org/eclipse/equinox/internal/p2/core/helpers/AbstractRepositoryManager.java 28 Feb 2009 20:40:00 -0000 >@@ -14,7 +14,6 @@ > import java.net.*; > import java.util.*; > import org.eclipse.core.runtime.*; >-import org.eclipse.core.runtime.jobs.Job; > import org.eclipse.core.runtime.preferences.IPreferencesService; > import org.eclipse.equinox.internal.p2.core.Activator; > import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; >@@ -44,24 +43,6 @@ > } > } > >- private class SaveJob extends Job { >- SaveJob() { >- super(Messages.repoMan_save); >- setSystem(true); >- } >- >- protected IStatus run(IProgressMonitor monitor) { >- try { >- Preferences node = getPreferences(); >- if (node != null) >- node.flush(); >- } catch (BackingStoreException e) { >- log("Error while saving repositories in preferences", e); //$NON-NLS-1$ >- } >- return Status.OK_STATUS; >- } >- } >- > public static final String ATTR_SUFFIX = "suffix"; //$NON-NLS-1$ > public static final String EL_FACTORY = "factory"; //$NON-NLS-1$ > public static final String EL_FILTER = "filter"; //$NON-NLS-1$ >@@ -78,7 +59,6 @@ > public static final String KEY_VERSION = "version"; //$NON-NLS-1$ > > public static final String NODE_REPOSITORIES = "repositories"; //$NON-NLS-1$ >- private static final long SAVE_SCHEDULE_DELAY = 500; > > /** > * Map of String->RepositoryInfo, where String is the repository key >@@ -100,8 +80,6 @@ > */ > private Map loadLocks = new HashMap(); > >- private final Job saveJob = new SaveJob(); >- > protected AbstractRepositoryManager() { > IProvisioningEventBus bus = (IProvisioningEventBus) ServiceHelper.getService(Activator.getContext(), IProvisioningEventBus.SERVICE_NAME); > if (bus != null) >@@ -897,7 +875,13 @@ > * Save the list of repositories to the file-system. > */ > private void saveToPreferences() { >- saveJob.schedule(SAVE_SCHEDULE_DELAY); >+ try { >+ Preferences node = getPreferences(); >+ if (node != null) >+ node.flush(); >+ } catch (BackingStoreException e) { >+ log("Error while saving repositories in preferences", e); //$NON-NLS-1$ >+ } > } > > /* (non-Javadoc) >@@ -933,14 +917,10 @@ > } > } > } >- if (changed) >+ if (changed) { >+ if (Tracing.DEBUG) >+ Tracing.debug("Unsaved preferences when shutting down " + getClass().getName()); //$NON-NLS-1$ > saveToPreferences(); >- //if there is a save job waiting, make sure it runs immediately before we discard state >- saveJob.wakeUp(); >- try { >- saveJob.join(); >- } catch (InterruptedException e) { >- //ignore > } > repositories = null; > unavailableRepositories = null;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 266205
: 127094