Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 365050 - Recursive create message when IRunnableWithProgress is started on editor creation and Navigator linking is enabled
Summary: Recursive create message when IRunnableWithProgress is started on editor crea...
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-29 08:27 EST by Toon Wouters CLA
Modified: 2019-11-14 03:37 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Toon Wouters CLA 2011-11-29 08:27:32 EST
Build Identifier: 201111090313

When the 'Link with editor' option is enabled on the common navigator and you then open a document from the navigator which creates an editor, and that editor starts an IRunnableWithProgress with ProgressManager.busyCursorWhile() the following exception is thrown:

'org.eclipse.ui.PartInitException: Warning: Detected recursive attempt by part com.id.scriptura.eclipse.editors.template.TemplateEditor to create itself (this is probably, but not necessarily, a bug)'

I noticed this was not occurring in 3.4 so I did some debugging in both 3.4 and 3.7 (we only use 3.4 and 3.7 as the base for our products, 3.5 and 3.6 were skipped, so I don't know about those).

What I found was that the EditorReference class had changed considerably between these two versions. In the new version an EditorReference is constructed using the IEditorInput which serves as the input to the editor part. While the old version (3.4) gets its intial values from a memento object. The fields of interest are 'name' and 'factoryId'. In the old version, they are initialized from the memento object and get a null value. In the new version, the name field is initialized to the input filename, and the factoryId from the persistable on the IEditorInput.

What does this have to do with the forementioned exception?

The exception is indirectly caused by the LinkEditorAction. When the IRunnableWithProgress is started using busyCursorWhile, this also checks for asynchronous messages that need to be processed (to keep the ui responsive i guess). One of these messages will be a UIJob created by the LinkEditorAction to activate the corresponding open editor when a file is selected in the navigator. Eventually the calls made by LinkEditorAction to activate the editor will end up in EditorManager which will try to find a reference to the requested editor part. This findEditor(s)() implementation works by retrieving a list of all open editors (in both 3.4 and 3.7 this includes the editor that is currently being created) and then checking the 'name' and 'factoryId' fields of those editor parts against the filename and factoryId of the IStructuredSelection information that the LinkEditorAction activatevateEditorJob received. In the old version, this will not match since the fields are null on the reference while having a value for the selection. In the new version they will match. After the reference to the editor part is found the LinkEditorAction will then call getPart() on the reference. But since the editor part is still being created, it will detect the part as not having been created yet (the part field of EditorReference is null) and so it will try to create it. Then it detects that its status is still 'STATE_CREATION_IN_PROGRESS' and so it throws the exception (and so it should).

To be honest I don't know which behavior is correct (the old one or the new one) but the fact is that if you enable the Link with editor option and then open an editor that uses busyCursorWhile during its creation, you will almost certainly get a PartInitException with a warning about a recursive creation attempt.

Or is this something we could have done wrong in our product implementation?

I'll include the stack trace below. It does contain some lines that reference some custom classes, but it should provide enough information.
If you need any more information please let me know.

org.eclipse.ui.PartInitException: Warning: Detected recursive attempt by part com.id.scriptura.eclipse.editors.template.TemplateEditor to create itself (this is probably, but not necessarily, a bug)
	at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:586)
	at org.eclipse.ui.internal.EditorReference.getEditor(EditorReference.java:289)
	at org.eclipse.ui.internal.EditorManager.findEditor(EditorManager.java:424)
	at org.eclipse.ui.internal.EditorManager.findEditor(EditorManager.java:402)
	at org.eclipse.ui.internal.WorkbenchPage.findEditor(WorkbenchPage.java:2178)
	at org.eclipse.ui.internal.navigator.resources.workbench.ResourceLinkHelper.activateEditor(ResourceLinkHelper.java:54)
	at org.eclipse.ui.internal.navigator.actions.LinkEditorAction$2.run(LinkEditorAction.java:78)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.navigator.actions.LinkEditorAction$1.runInUIThread(LinkEditorAction.java:76)
	at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:95)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.block(ModalContext.java:173)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:388)
	at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:507)
	at org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog.run(ProgressMonitorJobsDialog.java:275)
	at org.eclipse.ui.internal.progress.ProgressManager$5.run(ProgressManager.java:960)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:995)
	at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:970)
	at com.id.scriptura.eclipse.editors.template.gui.editor.TemplateEditor.createDocument(TemplateEditor.java:193)
	at id.erw.scriptura.eclipse.editors.template.gui.editor.layout.AbstractLayoutEditorPart.createPartControl(AbstractLayoutEditorPart.java:2127)
	at org.eclipse.ui.part.MultiPageEditorPart.addPage(MultiPageEditorPart.java:241)
	at org.eclipse.ui.part.MultiPageEditorPart.addPage(MultiPageEditorPart.java:211)
	at com.id.scriptura.eclipse.editors.template.gui.editor.AbstractScripturaEditor.createEditPage(AbstractScripturaEditor.java:2171)
	at com.id.scriptura.eclipse.editors.template.gui.editor.AbstractScripturaEditor.createPages(AbstractScripturaEditor.java:1691)
	at org.eclipse.ui.part.MultiPageEditorPart.createPartControl(MultiPageEditorPart.java:348)
	at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:670)
	at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:465)
	at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
	at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:313)
	at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
	at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)
	at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
	at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)
	at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1245)
	at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1198)
	at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1597)
	at org.eclipse.ui.internal.PartStack.add(PartStack.java:493)
	at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103)
	at org.eclipse.ui.internal.PartStack.add(PartStack.java:479)
	at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112)
	at org.eclipse.ui.internal.EditorSashContainer.addEditor(EditorSashContainer.java:63)
	at org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorAreaHelper.java:225)
	at org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAreaHelper.java:213)
	at org.eclipse.ui.internal.EditorManager.createEditorTab(EditorManager.java:808)
	at org.eclipse.ui.internal.EditorManager.openEditorFromDescriptor(EditorManager.java:707)
	at org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java:666)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2942)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2850)
	at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2842)
	at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2793)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2789)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2773)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2764)
	at org.eclipse.ui.ide.IDE.openEditor(IDE.java:651)
	at org.eclipse.ui.ide.IDE.openEditor(IDE.java:610)
	at org.eclipse.ui.actions.OpenFileAction.openFile(OpenFileAction.java:99)
	at org.eclipse.ui.actions.OpenSystemEditorAction.run(OpenSystemEditorAction.java:99)
	at org.eclipse.ui.actions.RetargetAction.run(RetargetAction.java:221)
	at org.eclipse.ui.navigator.CommonNavigatorManager$3.open(CommonNavigatorManager.java:185)
	at org.eclipse.ui.OpenAndLinkWithEditorHelper$InternalListener.open(OpenAndLinkWithEditorHelper.java:48)
	at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredViewer.java:866)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
	at org.eclipse.jface.viewers.StructuredViewer.fireOpen(StructuredViewer.java:864)
	at org.eclipse.jface.viewers.StructuredViewer.handleOpen(StructuredViewer.java:1152)
	at org.eclipse.ui.navigator.CommonViewer.handleOpen(CommonViewer.java:462)
	at org.eclipse.jface.viewers.StructuredViewer$6.handleOpen(StructuredViewer.java:1256)
	at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrategy.java:275)
	at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.java:269)
	at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:309)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at com.id.scriptura.application.designer.DesignerApplication.start(DesignerApplication.java:100)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1386)

Reproducible: Always

Steps to Reproduce:
1. Enabled the link with editor option on the common navigator
2. Open a document from the navigator that will create a new editor part that starts an IRunnableWithProgress using busyCursorWhile()
Comment 1 Lars Vogel CLA 2019-11-14 03:37:38 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

If the bug is still relevant, please remove the "stalebug" whiteboard tag.