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

Bug 312917

Summary: IllegalStateException on shutdown
Product: [Eclipse Project] Equinox Reporter: Olivier Thomann <Olivier_Thomann>
Component: FrameworkAssignee: Thomas Watson <tjwatson>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: aniefer, dj.houghton, gunnar, slamers, tjwatson
Version: 3.6Flags: dj.houghton: review+
aniefer: review+
Target Milestone: 3.6 RC2   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
patch none

Description Olivier Thomann CLA 2010-05-14 10:50:47 EDT
Using eclipse.buildId=I20100513-0800
java.version=1.6.0_20-ea
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=fr_CA
Command-line arguments:  -os win32 -ws win32 -arch x86 -console,

I got this error once I restarted Eclipse. It seemed to happen on shutdown.

No steps to reproduce.

java.lang.IllegalStateException: The service has been unregistered
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.unregister(ServiceRegistrationImpl.java:209)
at org.eclipse.osgi.framework.console.ConsoleSession.close(ConsoleSession.java:44)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.shutdown(FrameworkConsole.java:207)
at org.eclipse.osgi.framework.internal.core.ConsoleManager.removedService(ConsoleManager.java:192)
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:922)
at org.osgi.util.tracker.AbstractTracked.untrack(AbstractTracked.java:351)
at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:865)
at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:104)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:933)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:227)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:149)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:756)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:711)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.unregister(ServiceRegistrationImpl.java:225)
at org.eclipse.osgi.framework.internal.core.ConsoleManager.stopConsole(ConsoleManager.java:162)
at org.eclipse.core.runtime.adaptor.EclipseStarter.shutdown(EclipseStarter.java:412)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:198)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
Comment 1 Thomas Watson CLA 2010-05-17 11:00:23 EDT
reproduced.  Need to investigate for RC2.
Comment 2 Thomas Watson CLA 2010-05-17 11:29:55 EDT
Created attachment 168750 [details]
patch

The issue is close can get called as a result of unregistering the ConsoleSession service which would cause us to try and unregister the service again.  This bug got uncovered by the fix to bug312691.

We should catch the exception and ignore it.  We try to set some flag when we receive the unregistrating event but I think the more clean solution is to catch the exception and ignore to avoid having to pass around a new parameter or introduce some new field to set on ConsoleSession to avoid the exception.  The patch also includes nulling out the registration since it will be invalid after the unregistration.
Comment 3 Thomas Watson CLA 2010-05-17 11:30:37 EDT
DJ, please review.  This should be fixed since it is a regression.
Comment 4 Thomas Watson CLA 2010-05-17 11:30:54 EDT
Andrew, please review.
Comment 5 Thomas Watson CLA 2010-05-17 14:15:54 EDT
Patch released.
Comment 6 Andrew Niefer CLA 2010-05-19 11:27:18 EDT
*** Bug 313541 has been marked as a duplicate of this bug. ***
Comment 7 Olivier Thomann CLA 2010-05-25 15:01:26 EDT
Using eclipse.buildId=I20100520-1744
java.version=1.6.0_20-ea
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=fr_CA
Command-line arguments:  -os win32 -ws win32 -arch x86 -console,

I still get this error:
java.lang.IllegalStateException: The service has been unregistered
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.unregister(ServiceRegistrationImpl.java:209)
at org.eclipse.osgi.framework.internal.core.ConsoleManager.stopConsole(ConsoleManager.java:162)
at org.eclipse.core.runtime.adaptor.EclipseStarter.shutdown(EclipseStarter.java:412)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:198)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)

Is this a new problem or the same one? Is it supposed to be fixed in this build?
Comment 8 Thomas Watson CLA 2010-05-25 15:31:28 EDT
(In reply to comment #7)
> Is this a new problem or the same one? Is it supposed to be fixed in this
> build?

This appears to be a new issue.  Are you doing anything with the console before you shutdown?  Or do you simply start eclipse -console and do nothing with it, then on shutdown you get the error?  I am able to get the exception, but only if I disconnect from the built-in system in/out console (using the disconnect command).  Is that what you are doing to reproduce?
Comment 9 Olivier Thomann CLA 2010-05-25 15:35:49 EDT
(In reply to comment #8)
> This appears to be a new issue.  Are you doing anything with the console before
> you shutdown?  Or do you simply start eclipse -console and do nothing with it,
> then on shutdown you get the error?  I am able to get the exception, but only
> if I disconnect from the built-in system in/out console (using the disconnect
> command).  Is that what you are doing to reproduce?
No, I don't think so. I am not doing anything special. I got it twice in a row and now I don't get it anymore.
Weird. No idea how to reproduce it on my machine.
I reported it when I saw it in the error log file.
Comment 10 Thomas Watson CLA 2010-05-25 15:44:50 EDT
I opened bug314343 to track the new issue.  Please update that bug if you find another way to reproduce.
Comment 11 Gunnar Wagenknecht CLA 2010-05-31 08:15:42 EDT
*** Bug 315048 has been marked as a duplicate of this bug. ***