Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in JarEditor maybe in combination with sub-bundles #5951

Closed
chrisrueger opened this issue Dec 27, 2023 · 5 comments · Fixed by #5954
Closed

Exception in JarEditor maybe in combination with sub-bundles #5951

chrisrueger opened this issue Dec 27, 2023 · 5 comments · Fixed by #5954

Comments

@chrisrueger
Copy link
Contributor

chrisrueger commented Dec 27, 2023

Today I was experimenting with sub-bundles (as here) and I got this often.

  • Eclipse Version: 2023-09 (4.29.0) Build id: 20230907-1323
  • Bndtools 7.1.0.DEV-202312111642-g044afd1
java.lang.IllegalArgumentException: Error creating temp folder for JAREditor java.lang.NullPointerException: Cannot invoke "java.net.URI.hashCode()" because the return value of "org.eclipse.core.filesystem.provider.FileStore.toURI()" is null
	at org.eclipse.core.filesystem.provider.FileStore.hashCode(FileStore.java:340)
	at java.base/java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1901)
	at bndtools.jareditor.internal.JarFileSystem.lambda$getStore$0(JarFileSystem.java:227)
	at aQute.bnd.result.Ok.map(Ok.java:127)
	at bndtools.jareditor.internal.JarFileSystem.getStore(JarFileSystem.java:217)
	at org.eclipse.core.internal.filesystem.InternalFileSystemCore.getStore(InternalFileSystemCore.java:110)
	at org.eclipse.core.filesystem.EFS.getStore(EFS.java:479)
	at org.eclipse.core.internal.resources.AliasManager.addToLocationsMap(AliasManager.java:358)
	at org.eclipse.core.internal.resources.AliasManager.buildLocationsMap(AliasManager.java:395)
	at org.eclipse.core.internal.resources.AliasManager.checkStructuralChanges(AliasManager.java:657)
	at org.eclipse.core.internal.resources.AliasManager.hasNoAliases(AliasManager.java:519)
	at org.eclipse.core.internal.resources.AliasManager.updateAliases(AliasManager.java:613)
	at org.eclipse.core.internal.resources.Folder.create(Folder.java:116)
	at org.eclipse.core.internal.resources.Folder.create(Folder.java:129)
	at bndtools.jareditor.internal.TemporaryFile.lambda$tempFolder$0(TemporaryFile.java:44)
	at aQute.bnd.result.Ok.map(Ok.java:127)
	at bndtools.jareditor.internal.TemporaryFile.tempFolder(TemporaryFile.java:33)
	at bndtools.jareditor.internal.JARTreePage.getFolder(JARTreePage.java:142)
	at bndtools.jareditor.internal.JARTreePage.lambda$update$0(JARTreePage.java:107)
	at bndtools.jareditor.internal.JAREditor$1.run(JAREditor.java:134)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

	at aQute.bnd.result.Err.orElseThrow(Err.java:117)
	at bndtools.jareditor.internal.JARTreePage.getFolder(JARTreePage.java:143)
	at bndtools.jareditor.internal.JARTreePage.lambda$update$0(JARTreePage.java:107)
	at bndtools.jareditor.internal.JAREditor$1.run(JAREditor.java:134)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

this was another related stacktrace:

java.lang.NullPointerException: Cannot invoke "java.net.URI.hashCode()" because the return value of "org.eclipse.core.filesystem.provider.FileStore.toURI()" is null
	at org.eclipse.core.filesystem.provider.FileStore.hashCode(FileStore.java:340)
	at java.base/java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1901)
	at bndtools.jareditor.internal.JarFileSystem.lambda$getStore$0(JarFileSystem.java:227)
	at aQute.bnd.result.Ok.map(Ok.java:127)
	at bndtools.jareditor.internal.JarFileSystem.getStore(JarFileSystem.java:217)
	at org.eclipse.core.internal.filesystem.InternalFileSystemCore.getStore(InternalFileSystemCore.java:110)
	at org.eclipse.core.filesystem.EFS.getStore(EFS.java:479)
	at org.eclipse.core.internal.resources.AliasManager.addToLocationsMap(AliasManager.java:358)
	at org.eclipse.core.internal.resources.AliasManager.buildLocationsMap(AliasManager.java:395)
	at org.eclipse.core.internal.resources.AliasManager.checkStructuralChanges(AliasManager.java:657)
	at org.eclipse.core.internal.resources.AliasManager.hasNoAliases(AliasManager.java:519)
	at org.eclipse.core.internal.resources.AliasManager.updateAliases(AliasManager.java:613)
	at org.eclipse.core.internal.localstore.FileSystemResourceManager.internalWrite(FileSystemResourceManager.java:722)
	at org.eclipse.core.internal.resources.Project.writeDescription(Project.java:1457)
	at org.eclipse.core.internal.resources.Project.writeDescription(Project.java:1438)
	at org.eclipse.core.internal.resources.Resource.deleteResource(Resource.java:887)
	at org.eclipse.core.internal.localstore.DeleteVisitor.delete(DeleteVisitor.java:71)
	at org.eclipse.core.internal.localstore.DeleteVisitor.visit(DeleteVisitor.java:156)
	at org.eclipse.core.internal.localstore.UnifiedTree.accept(UnifiedTree.java:119)
	at org.eclipse.core.internal.localstore.FileSystemResourceManager.delete(FileSystemResourceManager.java:414)
	at org.eclipse.core.internal.resources.ResourceTree.internalDeleteFolder(ResourceTree.java:364)
	at org.eclipse.core.internal.resources.ResourceTree.standardDeleteFolder(ResourceTree.java:816)
	at org.eclipse.core.internal.resources.Resource.unprotectedDelete(Resource.java:1839)
	at org.eclipse.core.internal.resources.Resource.delete(Resource.java:808)
	at org.eclipse.core.internal.resources.Resource.delete(Resource.java:777)
	at bndtools.jareditor.internal.TemporaryFile.dispose(TemporaryFile.java:72)
	at bndtools.jareditor.internal.JARTreePage.setFolder(JARTreePage.java:120)
	at bndtools.jareditor.internal.JARTreePage.dispose(JARTreePage.java:90)
	at org.eclipse.ui.forms.editor.FormEditor.dispose(FormEditor.java:410)
	at bndtools.jareditor.internal.JAREditor.dispose(JAREditor.java:86)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.invalidate(CompatibilityPart.java:264)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.destroy(CompatibilityPart.java:421)
	at jdk.internal.reflect.GeneratedMethodAccessor80.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:971)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:936)
	at org.eclipse.e4.core.internal.di.InjectorImpl.uninject(InjectorImpl.java:184)
	at org.eclipse.e4.core.internal.di.Requestor.uninject(Requestor.java:177)
	at org.eclipse.e4.core.internal.contexts.ContextObjectSupplier$ContextInjectionListener.update(ContextObjectSupplier.java:89)
	at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.update(TrackableComputationExt.java:103)
	at org.eclipse.e4.core.internal.contexts.EclipseContext.removeListenersTo(EclipseContext.java:487)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.uninject(ContextInjectionFactory.java:184)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:947)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:861)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:845)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.subscribeTopicToBeRendered(PartRenderingEngine.java:185)
	at jdk.internal.reflect.GeneratedMethodAccessor68.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
	at org.eclipse.e4.core.di.internal.extensions.EventObjectSupplier$DIEventHandler.handleEvent(EventObjectSupplier.java:92)
	at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:205)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:203)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:151)
	at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:133)
	at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:75)
	at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:44)
	at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:55)
	at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:63)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:424)
	at org.eclipse.e4.ui.model.application.ui.impl.UIElementImpl.setToBeRendered(UIElementImpl.java:314)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.hidePart(PartServiceImpl.java:1410)
	at org.eclipse.ui.internal.WorkbenchPage.hidePart(WorkbenchPage.java:1543)
	at org.eclipse.ui.internal.WorkbenchPage.hidePart(WorkbenchPage.java:1495)
	at org.eclipse.ui.internal.WorkbenchPage.closeEditors(WorkbenchPage.java:1465)
	at org.eclipse.ui.internal.WorkbenchPage.closeEditor(WorkbenchPage.java:1589)
	at org.eclipse.ui.internal.CloseEditorHandler.execute(CloseEditorHandler.java:50)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:283)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:97)
	at jdk.internal.reflect.GeneratedMethodAccessor62.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:300)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:234)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:156)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:488)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:485)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:213)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.executeCommand(KeyBindingDispatcher.java:308)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.press(KeyBindingDispatcher.java:580)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.processKeyEvent(KeyBindingDispatcher.java:655)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.filterKeySequenceBindings(KeyBindingDispatcher.java:439)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher$KeyDownFilter.handleEvent(KeyBindingDispatcher.java:96)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1217)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4641)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1524)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1547)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1532)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1561)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1557)
	at org.eclipse.swt.widgets.Tree.sendKeyEvent(Tree.java:2753)
	at org.eclipse.swt.widgets.Control.keyDown(Control.java:2470)
	at org.eclipse.swt.widgets.Composite.keyDown(Composite.java:620)
	at org.eclipse.swt.widgets.Tree.keyDown(Tree.java:2114)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:6324)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
	at org.eclipse.swt.widgets.Widget.callSuper(Widget.java:236)
	at org.eclipse.swt.widgets.Widget.windowSendEvent(Widget.java:2264)
	at org.eclipse.swt.widgets.Shell.windowSendEvent(Shell.java:2511)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:6444)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
	at org.eclipse.swt.widgets.Display.applicationSendEvent(Display.java:5692)
	at org.eclipse.swt.widgets.Display.applicationProc(Display.java:5831)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
	at org.eclipse.swt.internal.cocoa.NSApplication.sendEvent(NSApplication.java:117)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3986)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:342)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:645)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:342)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:552)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:651)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:588)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1459)


Reproducer Repo

I created a small reproducer repo at https://github.com/chrisrueger/bndtools-jareditorbug
It's a bnd workspace.

Steps to reproduce

I could not exactly reproduce the initally report stack trace but I think a related behavior:

  1. import the workspace

Notice there are 2 .bnd files.
Sub-Bundles are enabled.
My expectation is that an my.bundle1.api.jar is to be built

image
  1. Open the /generated/my.bundle1.api.jar in the JAR Editor and switch to the Print tab (this switch seems to be important)
    May this already triggers the exception report initally. But for me it just happened the first time.
image
  1. Close Eclipse (make sure you are in the JAR Editor in the Print tab)
  2. Start Eclipse again

You should see something like this:

image
Reading zip file
Error creating temp folder for JAREditor org.eclipse.core.internal.resources.ResourceException(/.BndtoolsJAREditorTempFiles/temp/10000002)[374]: java.lang.Exception: Resource '/.BndtoolsJAREditorTempFiles/temp/10000002' already exists.
	at org.eclipse.core.internal.resources.ResourceException.provideStackTrace(ResourceException.java:42)
	at org.eclipse.core.internal.resources.ResourceException.<init>(ResourceException.java:38)
	at org.eclipse.core.internal.resources.Resource.checkDoesNotExist(Resource.java:346)
	at org.eclipse.core.internal.resources.Resource.checkDoesNotExist(Resource.java:333)
	at org.eclipse.core.internal.resources.Folder.assertCreateRequirements(Folder.java:40)
	at org.eclipse.core.internal.resources.Folder.create(Folder.java:101)
	at org.eclipse.core.internal.resources.Folder.create(Folder.java:129)
	at bndtools.jareditor.internal.TemporaryFile.lambda$tempFolder$0(TemporaryFile.java:44)
	at aQute.bnd.result.Ok.map(Ok.java:127)
	at bndtools.jareditor.internal.TemporaryFile.tempFolder(TemporaryFile.java:33)
	at bndtools.jareditor.internal.JARTreePage.getFolder(JARTreePage.java:142)
	at bndtools.jareditor.internal.JARTreePage.lambda$update$0(JARTreePage.java:107)
	at bndtools.jareditor.internal.JAREditor$1.run(JAREditor.java:134)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)


This stacktrace and the stacktrace in the issue description share the same line:

at bndtools.jareditor.internal.TemporaryFile.lambda$tempFolder$0(TemporaryFile.java:44)

To reproduce it over and over again do the following:

  1. Close the Jar Editor of /generated/my.bundle1.api.jar
  2. Reopen the JAR Editor /generated/my.bundle1.api.jar and open the Print tab.
  3. Close Eclipse (make sure you are in the JAR Editor)
  4. Start Eclipse again

Boom. Error again.
Error does not happen when you skip 5. Close the Jar Editor

Repeat 5-8 and you always get the error.

image
@chrisrueger
Copy link
Contributor Author

@pkriens I tried adding info on how to reproduce.
Maybe you could have a look. I found you worked on it in 73fae3c

Maybe something is going on here https://github.com/bndtools/bnd/blob/master/bndtools.jareditor/src/bndtools/jareditor/internal/TemporaryFile.java#L44

@chrisrueger
Copy link
Contributor Author

chrisrueger commented Dec 29, 2023

Update: I retested with latest snapshot 7.1.0.DEV-202312261441-gd759351 , because I saw #5897 & #5910 and thought it might be fixed. But it seems I already had the changes of #5910 in my previous snapshot 7.1.0.DEV-202312111642-g044afd1

@chrisrueger
Copy link
Contributor Author

chrisrueger commented Dec 29, 2023

Update:
I debugged a bit further. It might be a race condition / heisenbug (since when I debug I cannot reproduce it):

image

This breakpoint is hit when the Eclipse instance is started. You can see that two threads do this parallel.

Before this the same method is already called by this stack trace at least twice and the loading variable has already been counted up to 1.

image image

I found out, that bndtools.jareditor.internal.JARTreePage.update() is only called twice on Eclipse-instance start when there is a JAR-Editor open already.

Notice the two different stack traces in the screenshot above:
bndtools.jareditor.internal.JARTreePage.setActive(boolean)
is called from two different places:

image

When there is no JAR-Editor open then bndtools.jareditor.internal.JARTreePage.update() is not called.
When I open a .jar file manually (double click) then it is just called once.

Summary: I think all the stack traces above are related. I hit a problem at different places but in every stacktrace JARTreePage.lambda$update$0(JARTreePage.java:107) was involved somehow.

I hope this helps a bit to identify the issue.

@chrisrueger
Copy link
Contributor Author

chrisrueger commented Dec 29, 2023

@pkriens I created #5954 and with this I have not managed to get the following error anymore:

image

I restarted the Eclipse debug instance multiple times.

I am no expert in concurrency so feel free to improve as you see fit - in case synchronized method is too broad.

@pkriens
Copy link
Member

pkriens commented Jan 8, 2024

Herculean work man!

I am going to take this and keep it in mind. The fix seems ok. I vaguely recall I also had a problem in this area and did a fix but either age, alzheimer, or korsakov makes me unable to recall. I've been working on some stuff might be in there, will take a look.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants