Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 266205

Summary: IllegalStateException while saving preferences
Product: [Eclipse Project] Equinox Reporter: Olivier Thomann <Olivier_Thomann>
Component: p2Assignee: John Arthorne <john.arthorne>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: matthew, simon_kaegi
Version: 3.4   
Target Milestone: 3.5 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Fix none

Description Olivier Thomann CLA 2009-02-25 15:19:46 EST
I got this in the .log file:
I am using  I20090224-0800.

org.osgi.service.prefs.BackingStoreException: An error occurred while saving preferences for profile SDKProfile
at org.eclipse.equinox.internal.p2.engine.ProfilePreferences.save(ProfilePreferences.java:173)
at org.eclipse.core.internal.preferences.EclipsePreferences.flush(EclipsePreferences.java:352)
at org.eclipse.core.internal.preferences.EclipsePreferences.flush(EclipsePreferences.java:340)
at org.eclipse.equinox.internal.p2.core.helpers.AbstractRepositoryManager$SaveJob.run(AbstractRepositoryManager.java:57)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.lang.IllegalStateException: Profile SDKProfile is not current.
at org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry.lockProfile(SimpleProfileRegistry.java:663)
at org.eclipse.equinox.internal.provisional.p2.engine.Engine.perform(Engine.java:43)
at org.eclipse.equinox.internal.p2.engine.ProfilePreferences.save(ProfilePreferences.java:163)
... 4 more
Comment 1 John Arthorne CLA 2009-02-25 16:27:59 EST
Olivier, by any chance to do have the entire stack trace? It seems to be cut off...
Comment 2 Olivier Thomann CLA 2009-02-25 20:30:45 EST
This is all I got. Sorry. If I can get it again, I'll try to provide steps.
Comment 3 John Arthorne CLA 2009-02-28 15:43:02 EST
Created attachment 127094 [details]
Fix

This fix removes the recursion at the engine level by putting the preference saving in a job. Thus the engine session that persists preferences will always be in its own thread and there will be no reentrant call to the engine.
Comment 4 John Arthorne CLA 2009-02-28 15:44:36 EST
I didn't mention, the cause of the failure here is that we are calling the engine recursively. This means the inner engine call has a stale profile objects because the profile is currently being modified by the outer engine call. This has bad implications for the profile object's lifecycle so recursion is best avoided (changes made in inner engine call could conflict with profile changes in outer engine call, and reconciling the changes would be difficult).
Comment 5 John Arthorne CLA 2009-02-28 15:46:15 EST
Fix released in HEAD.