Bug 540888 - [registry] PlatformObject's getAdapter(Class<T>) leaks InvalidRegistryObjectException
Summary: [registry] PlatformObject's getAdapter(Class<T>) leaks InvalidRegistryObjectE...
Status: CLOSED DUPLICATE of bug 548510
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Components (show other bugs)
Version: 4.10   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: equinox.components-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 520098 542086 548510
  Show dependency tree
 
Reported: 2018-11-07 08:44 EST by Mykola Nikishov CLA
Modified: 2020-04-06 06:45 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mykola Nikishov CLA 2018-11-07 08:44:19 EST
It looks wrong to me that org.eclipse.core.runtime.PlatformObject's
getAdapter(Class<T>) leaks
org.eclipse.core.runtime.InvalidRegistryObjectException to the
callers, I would expect it to return null as javadoc says.

I do not have steps to reproduce, just a single Eclipse installation
that on every restart fails to restore the editor that was active
before shutdown:

    eclipse.buildId=4.10.0.I20181010-1800
    java.version=1.8.0_181
    java.vendor=Oracle Corporation
    BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
    Framework arguments:  -product org.eclipse.epp.package.committers.product
    Command-line arguments:  -data file://eclipse-workspace/ -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.committers.product

    org.eclipse.ui
    Error
    Wed Nov 07 14:39:09 EET 2018
    Unable to initialize part

    org.eclipse.core.runtime.InvalidRegistryObjectException: Invalid registry object
	    at org.eclipse.core.internal.registry.RegistryObjectManager.basicGetObject(RegistryObjectManager.java:277)
	    at org.eclipse.core.internal.registry.RegistryObjectManager.getObject(RegistryObjectManager.java:267)
	    at org.eclipse.core.internal.registry.ConfigurationElementHandle.getConfigurationElement(ConfigurationElementHandle.java:29)
	    at org.eclipse.core.internal.registry.ConfigurationElementHandle.getChildren(ConfigurationElementHandle.java:53)
	    at org.eclipse.core.internal.adapter.AdapterFactoryProxy.getAdapterNames(AdapterFactoryProxy.java:97)
	    at org.eclipse.core.internal.runtime.AdapterManager.addFactoriesFor(AdapterManager.java:109)
	    at org.eclipse.core.internal.runtime.AdapterManager.getFactories(AdapterManager.java:212)
	    at org.eclipse.core.internal.runtime.AdapterManager.getAdapter(AdapterManager.java:295)
	    at org.eclipse.core.runtime.PlatformObject.getAdapter(PlatformObject.java:71)
	    at org.eclipse.ui.part.FileEditorInput.getAdapter(FileEditorInput.java:242)
	    at org.eclipse.ui.texteditor.DocumentProviderRegistry.getDocumentProvider(DocumentProviderRegistry.java:314)
	    at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.setDocumentProvider(AbstractDecoratedTextEditor.java:1440)
	    at org.eclipse.ui.texteditor.AbstractTextEditor.updateDocumentProvider(AbstractTextEditor.java:4104)
	    at org.eclipse.ui.texteditor.AbstractTextEditor.doSetInput(AbstractTextEditor.java:4159)
	    at org.eclipse.ui.texteditor.StatusTextEditor.doSetInput(StatusTextEditor.java:260)
	    at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.doSetInput(AbstractDecoratedTextEditor.java:1476)

Another error log entry:

    eclipse.buildId=4.10.0.I20181010-1800
    java.version=1.8.0_181
    java.vendor=Oracle Corporation
    BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
    Framework arguments:  -product org.eclipse.epp.package.committers.product
    Command-line arguments:  -data file://eclipse-workspace/ -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.committers.product

    org.eclipse.ui.workbench
    Error
    Wed Nov 07 14:39:09 EET 2018
    Problems occurred when invoking code from plug-in: "org.eclipse.ui.workbench".

    org.eclipse.core.runtime.InvalidRegistryObjectException: Invalid registry object
	    at org.eclipse.core.internal.registry.RegistryObjectManager.basicGetObject(RegistryObjectManager.java:277)
	    at org.eclipse.core.internal.registry.RegistryObjectManager.getObject(RegistryObjectManager.java:267)
	    at org.eclipse.core.internal.registry.ConfigurationElementHandle.getConfigurationElement(ConfigurationElementHandle.java:29)
	    at org.eclipse.core.internal.registry.ConfigurationElementHandle.getChildren(ConfigurationElementHandle.java:53)
	    at org.eclipse.core.internal.adapter.AdapterFactoryProxy.getAdapterNames(AdapterFactoryProxy.java:97)
	    at org.eclipse.core.internal.runtime.AdapterManager.addFactoriesFor(AdapterManager.java:109)
	    at org.eclipse.core.internal.runtime.AdapterManager.getFactories(AdapterManager.java:212)
	    at org.eclipse.core.internal.runtime.AdapterManager.getAdapter(AdapterManager.java:295)
	    at org.eclipse.core.runtime.PlatformObject.getAdapter(PlatformObject.java:71)
	    at org.eclipse.ui.part.FileEditorInput.getAdapter(FileEditorInput.java:242)
	    at org.eclipse.core.runtime.Adapters.adapt(Adapters.java:62)
	    at org.eclipse.core.runtime.Adapters.adapt(Adapters.java:110)
	    at org.eclipse.ui.internal.ide.actions.ProjectPropertyDialogAction.getProject(ProjectPropertyDialogAction.java:116)
	    at org.eclipse.ui.internal.ide.actions.ProjectPropertyDialogAction.partActivated(ProjectPropertyDialogAction.java:98)
Comment 1 Thomas Watson CLA 2018-11-07 15:49:43 EST
I'm not sure what could have happened, but it appears the registry cache may be invalid or corrupted.  Try starting with -clean.
Comment 2 Mykola Nikishov CLA 2018-12-04 07:03:35 EST
(In reply to Thomas Watson from comment #1)
> I'm not sure what could have happened
Actually, I'm not looking for the fix in the registry cache. Is it reasonable to suggest that PlatformObject should catch InvalidRegistryObjectException and just return null, as client might expect according to Javadoc?
Comment 3 Andrey Loskutov CLA 2018-12-05 14:36:19 EST
(In reply to Mykola Nikishov from comment #2)
> (In reply to Thomas Watson from comment #1)
> > I'm not sure what could have happened
> Actually, I'm not looking for the fix in the registry cache. Is it
> reasonable to suggest that PlatformObject should catch
> InvalidRegistryObjectException and just return null, as client might expect
> according to Javadoc?

Yes, this is what I would expect as a client. I would say org.eclipse.core.internal.runtime.AdapterManager.getAdapter(Object, Class<T>) should try/catch/log InvalidRegistryObjectException and return null in that case. I can't imagine every client has to guard the code around this getAdapter() call against invalid registry state.
Comment 4 Mykola Nikishov CLA 2018-12-10 12:05:42 EST
And here is one more that affects ProblemTreeViewer:

    eclipse.buildId=4.10.0.I20181031-1800
    java.version=1.8.0_191
    java.vendor=Oracle Corporation
    BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
    Framework arguments:  -product org.eclipse.epp.package.committers.product
    Command-line arguments:  -data file:/eclipse-workspace/ -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.committers.product

    This is a continuation of log file /eclipse-workspace/.metadata/.bak_0.log
    Created Time: 2018-12-10 17:43:35.466
    org.eclipse.ui
    Error
    Mon Dec 10 18:40:19 EET 2018
    Unhandled event loop exception

    org.eclipse.core.runtime.InvalidRegistryObjectException: Invalid registry object
	    at org.eclipse.core.internal.registry.RegistryObjectManager.basicGetObject(RegistryObjectManager.java:277)
	    at org.eclipse.core.internal.registry.RegistryObjectManager.getObject(RegistryObjectManager.java:267)
	    at org.eclipse.core.internal.registry.ConfigurationElementHandle.getConfigurationElement(ConfigurationElementHandle.java:29)
	    at org.eclipse.core.internal.registry.ConfigurationElementHandle.getChildren(ConfigurationElementHandle.java:53)
	    at org.eclipse.core.internal.adapter.AdapterFactoryProxy.getAdapterNames(AdapterFactoryProxy.java:97)
	    at org.eclipse.core.internal.runtime.AdapterManager.addFactoriesFor(AdapterManager.java:109)
	    at org.eclipse.core.internal.runtime.AdapterManager.getFactories(AdapterManager.java:212)
	    at org.eclipse.core.internal.runtime.AdapterManager.getAdapter(AdapterManager.java:295)
	    at org.eclipse.buildship.ui.internal.navigator.BuildFolderViewerFilter.select(BuildFolderViewerFilter.java:34)
	    at org.eclipse.jdt.internal.ui.viewsupport.ProblemTreeViewer.isFiltered(ProblemTreeViewer.java:301)
	    at org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$PackageExplorerProblemTreeViewer.isFiltered(PackageExplorerPart.java:291)
	    at org.eclipse.jdt.internal.ui.viewsupport.ProblemTreeViewer.containsNonFiltered(ProblemTreeViewer.java:282)
	    at org.eclipse.jdt.internal.ui.viewsupport.ProblemTreeViewer.hasFilteredChildren(ProblemTreeViewer.java:249)
	    at org.eclipse.jdt.internal.ui.viewsupport.ProblemTreeViewer.isExpandable(ProblemTreeViewer.java:237)
Comment 5 Eric Milles CLA 2019-12-28 11:27:15 EST
I have a situation that creates these errors. Many bundles may declare adapter factory via plugin.xml. If one of those bundles is refreshed before it is started, the adapter registry contains an invalid reference.  Any use will result in the registry exceptions.

It is often the case that these invalid adapter factories are not even the ones used to adapt an object.  But they fail fast just trying to determine what types that accept and produce.

I agree that AdapterFactoryProxy.getAdapterNames should be catching InvalidRegistryObjectException, logging it and continuing the search.
Comment 6 Eric Milles CLA 2019-12-28 13:06:58 EST
#548510 has proposed change.
Comment 7 Andrey Loskutov CLA 2019-12-28 17:10:09 EST
(In reply to Eric Milles from comment #5)
> I have a situation that creates these errors. Many bundles may declare
> adapter factory via plugin.xml. If one of those bundles is refreshed before
> it is started, the adapter registry contains an invalid reference

What du you mean by "bundle is refreshed"?
Comment 8 Lars Vogel CLA 2020-04-06 06:45:08 EDT
(In reply to Eric Milles from comment #6)
> #548510 has proposed change.

Marking this one as dup of Bug 548510

*** This bug has been marked as a duplicate of bug 548510 ***