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

Bug 414799

Summary: NPE opening Review Explorer
Product: z_Archived Reporter: Sam Davis <sam.davis>
Component: MylynAssignee: Project Inbox <mylyn-triaged>
Status: RESOLVED WORKSFORME QA Contact:
Severity: minor    
Priority: P2 CC: milesparker, tomasz.zarna
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on:    
Bug Blocks: 415490    
Attachments:
Description Flags
mylyn/context/zip none

Description Sam Davis CLA 2013-08-09 16:40:12 EDT
Suddenly I get this whenever I open the Review Explorer:

java.lang.NullPointerException
	at org.eclipse.mylyn.internal.reviews.ui.views.ReviewExplorer.setReview(ReviewExplorer.java:528)
	at org.eclipse.mylyn.internal.reviews.ui.views.ReviewExplorer$2.partActivated(ReviewExplorer.java:172)
Comment 1 Sam Davis CLA 2013-08-09 16:55:57 EDT
And now I'm getting this which when I try to sync reviews:


org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Widget is disposed)
	at org.eclipse.swt.SWT.error(SWT.java:4361)
	at org.eclipse.swt.SWT.error(SWT.java:4276)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4144)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
	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:353)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
Caused by: org.eclipse.swt.SWTException: Widget is disposed
	at org.eclipse.swt.SWT.error(SWT.java:4361)
	at org.eclipse.swt.SWT.error(SWT.java:4276)
	at org.eclipse.swt.SWT.error(SWT.java:4247)
	at org.eclipse.swt.widgets.Widget.error(Widget.java:468)
	at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:340)
	at org.eclipse.swt.widgets.Tree.getItems(Tree.java:3251)
	at org.eclipse.jface.viewers.TreeViewer.getChildren(TreeViewer.java:171)
	at org.eclipse.jface.viewers.AbstractTreeViewer.internalCollectExpandedItems(AbstractTreeViewer.java:1603)
	at org.eclipse.jface.viewers.AbstractTreeViewer.getExpandedElements(AbstractTreeViewer.java:1195)
	at org.eclipse.mylyn.internal.reviews.ui.views.ReviewExplorer.updatePerservingSelection(ReviewExplorer.java:495)
	at org.eclipse.mylyn.internal.reviews.ui.views.ReviewExplorer$1.updated(ReviewExplorer.java:116)
	at org.eclipse.mylyn.internal.reviews.ui.views.ReviewExplorer$1.updated(ReviewExplorer.java:1)
	at org.eclipse.mylyn.reviews.core.spi.remote.emf.RemoteEmfConsumer$ConsumerAdapter.notifyChanged(RemoteEmfConsumer.java:91)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
	at org.eclipse.emf.common.notify.impl.NotificationChainImpl.dispatch(NotificationChainImpl.java:98)
	at org.eclipse.emf.common.notify.impl.NotificationChainImpl.dispatch(NotificationChainImpl.java:86)
	at org.eclipse.mylyn.reviews.core.spi.remote.emf.RemoteEmfConsumer.applyModel(RemoteEmfConsumer.java:250)
	at org.eclipse.mylyn.reviews.core.spi.remote.JobRemoteService$3.run(JobRemoteService.java:95)
	at org.eclipse.ui.internal.UILockListener.doPendingWork(UILockListener.java:164)
	at org.eclipse.ui.internal.UISynchronizer$3.run(UISynchronizer.java:158)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
	... 23 more
Comment 2 Steffen Pingel CLA 2013-08-11 23:25:20 EDT
Looks like the UI isn't checking for disposal when it should.
Comment 3 Miles Parker CLA 2013-08-12 13:24:23 EDT
(In reply to comment #2)
> Looks like the UI isn't checking for disposal when it should.

Yeah, possibly. It didn't occur to me that you'd really need a UI in this case. But that would imply that the whole workbench would be in the of process shutting down, yet Same reports that he was actually just opening the review.
(In reply to comment #1)

> And now I'm getting this which when I try to sync reviews:
> 
> 
> org.eclipse.swt.SWTException: Failed to execute runnable
> (org.eclipse.swt.SWTException: Widget is disposed)
> at org.eclipse.swt.SWT.error(SWT.java:4361)
> at org.eclipse.swt.SWT.error(SWT.java:4276)

Ok, are you sure you didn't opne the Review explorer and then close it or something? Because combined w/ the notificaiton issues, that might result in this.
Comment 4 Tomasz Zarna CLA 2013-08-13 09:11:25 EDT
(In reply to comment #2)
> Looks like the UI isn't checking for disposal when it should.

Review if the check added: https://git.eclipse.org/r/#/c/15418/
Comment 5 Tomasz Zarna CLA 2013-08-13 09:24:19 EDT
(In reply to comment #4)
> Review if the check added: https://git.eclipse.org/r/#/c/15418/

sed s/if/with/

(In reply to comment #0)
> java.lang.NullPointerException
> org.eclipse.mylyn.internal.reviews.ui.views.ReviewExplorer.setReview(ReviewExplorer.java:528)

Review checking if repository is not null: https://git.eclipse.org/r/#/c/15419/
Comment 6 Miles Parker CLA 2013-08-13 13:34:35 EDT
(In reply to comment #5)

> Review checking if repository is not null: https://git.eclipse.org/r/#/c/15419/

See my comment on review, but I'm not sure we understand why the repository is null in this case? If we don't, I'm not sure just adding a null check is the way to go here.
Comment 7 Steffen Pingel CLA 2013-08-18 17:31:11 EDT
What the status here? I'd rather go with a null check for now unless we have clear steps to reproduce the problem. Assigning to Tomek who has done most of the work up to this point.
Comment 8 Tomasz Zarna CLA 2013-08-19 09:12:02 EDT
(In reply to comment #7)
> What the status here?

I pushed https://git.eclipse.org/r/#/c/15419/ to fix the NPE, but I admit I had no idea of the culprit at that time. The change was marked as RFC (request for comment), and I was hoping to get some hints from Miles why the repo is null.

Here are my hypotheses:
* the part (ReviewExplorer) gets activated while the editor is being disposed (this is when Review's container is set to null [1])
* the part gets activated for a Review which has not been fully/correctly initialized

Miles are any of these possible (worth investigating) or do you have any other idea what might have caused this?

Sam, regarding comment 0, do you have "Link with Editor" mode enabled for the Review explorer? Or any other non-default settings applied? How do you open the explorer?

[1] Thread [main] (Suspended (entry into method eBasicSetContainer in BasicEObjectImpl))	
	Review(BasicEObjectImpl).eBasicSetContainer(InternalEObject, int, NotificationChain) line: 1294	
	Review.basicSetRepository(IRepository, NotificationChain) line: 371	
	Review.eInverseRemove(InternalEObject, int, NotificationChain) line: 653	
	Review(BasicEObjectImpl).eInverseRemove(InternalEObject, int, Class<?>, NotificationChain) line: 1437	
	EObjectContainmentWithInverseEList$Resolving<E>(EcoreEList<E>).inverseRemove(E, NotificationChain) line: 312	
	EObjectContainmentWithInverseEList$Resolving<E>(NotifyingListImpl<E>).remove(int) line: 740	
	EObjectContainmentWithInverseEList$Resolving<E>(AbstractEList<E>).remove(Object) line: 460	
	GerritRemoteFactoryProvider(AbstractRemoteEditFactoryProvider<ERootObject,EChildObject>).close(EObject) line: 232	
	RemoteEmfConsumer<EParentObjectType,EObjectType,LocalKeyType,RemoteType,RemoteKeyType,ObjectCurrentType>.dispose() line: 251	
	RemoteEmfConsumer<EParentObjectType,EObjectType,LocalKeyType,RemoteType,RemoteKeyType,ObjectCurrentType>.release() line: 294	
	RemoteEmfConsumer<EParentObjectType,EObjectType,LocalKeyType,RemoteType,RemoteKeyType,ObjectCurrentType>.removeObserver(RemoteEmfObserver<EParentObjectType,EObjectType,LocalKeyType,ObjectCurrentType>) line: 289	
	ReviewSetContentSection$2(RemoteEmfObserver<EParentObjectType,EObjectType,LocalKeyType,ObjectCurrentType>).dispose() line: 83	
	ReviewSetContentSection.dispose() line: 330	
	PatchSetSection(ReviewSetSection).dispose() line: 96	
	FormPage$PageForm(ManagedForm).dispose() line: 174	
	GerritTaskEditorPage(FormPage).dispose() line: 178	
	GerritTaskEditorPage(AbstractTaskEditorPage).dispose() line: 902	
	GerritTaskEditorPage(AbstractReviewTaskEditorPage).dispose() line: 136	
	TaskEditor(FormEditor).dispose() line: 403	
	TaskEditor(SharedHeaderFormEditor).dispose() line: 160	
	TaskEditor.dispose() line: 519	
	EditorReference(WorkbenchPartReference).doDisposePart() line: 737	
	EditorReference.doDisposePart() line: 327	
	EditorReference(WorkbenchPartReference).dispose() line: 684	
	WorkbenchPage.disposePart(WorkbenchPartReference) line: 1810	
	WorkbenchPage.handleDeferredEvents() line: 1514	
	WorkbenchPage.deferUpdates(boolean) line: 1498	
	WorkbenchPage.closeEditors(IEditorReference[], boolean) line: 1472	
	WorkbenchPage.closeEditor(IEditorReference, boolean) line: 1527	
	EditorPane.doHide() line: 61	
	EditorStack(PartStack).close(IPresentablePart) line: 537	
	EditorStack.close(IPresentablePart[]) line: 206	
	PartStack$1.close(IPresentablePart[]) line: 120	
	TabbedStackPresentation$1.handleEvent(TabFolderEvent) line: 83	
	DefaultTabFolder(AbstractTabFolder).fireEvent(TabFolderEvent) line: 269	
	DefaultTabFolder(AbstractTabFolder).fireEvent(int, AbstractTabItem) line: 278	
	DefaultTabFolder.access$1(DefaultTabFolder, int, AbstractTabItem) line: 1	
	DefaultTabFolder$1.closeButtonPressed(CTabItem) line: 71	
	PaneFolder.notifyCloseListeners(CTabItem) line: 631	
	PaneFolder$3.close(CTabFolderEvent) line: 206	
	CTabFolder.onMouse(Event) line: 1599	
	CTabFolder$1.handleEvent(Event) line: 261	
	EventTable.sendEvent(Event) line: 84	
	CTabFolder(Widget).sendEvent(Event) line: 1053	
	Display.runDeferredEvents() line: 4169	
	Display.readAndDispatch() line: 3758	
	Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2701	
	Workbench.runUI() line: 2665	
	Workbench.access$4(Workbench) line: 2499	
	Workbench$7.run() line: 679	
	Realm.runWithDefault(Realm, Runnable) line: 332	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 668	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149	
	IDEApplication.start(IApplicationContext) line: 124	
	EclipseAppHandle.run(Object) line: 196	
	EclipseAppLauncher.runApplication(Object) line: 110	
	EclipseAppLauncher.start(Object) line: 79	
	EclipseStarter.run(Object) line: 353	
	EclipseStarter.run(String[], Runnable) line: 180	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 57	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43	
	Method.invoke(Object, Object...) line: 606	
	Main.invokeFramework(String[], URL[]) line: 629	
	Main.basicRun(String[]) line: 584	
	Main.run(String[]) line: 1438	
	Main.main(String[]) line: 1414
Comment 9 Tomasz Zarna CLA 2013-08-19 09:12:11 EDT
Created attachment 234530 [details]
mylyn/context/zip
Comment 10 Steffen Pingel CLA 2013-08-19 10:22:32 EDT
(In reply to comment #8)
> Here are my hypotheses:
> * the part (ReviewExplorer) gets activated while the editor is being disposed
> (this is when Review's container is set to null [1])

Ah, that's interesting. Is that to avoid model cross references when persisting the review model? Where is that done exactly?

If reviews can have a "disposed" state we would need to add checks everywhere since the models are shared to reviews could be disposed at any time while clients still hold references.
Comment 11 Tomasz Zarna CLA 2013-08-19 10:37:45 EDT
(In reply to comment #10)
> Ah, that's interesting. Is that to avoid model cross references when persisting
> the review model? Where is that done exactly?

Review.eInverseRemove(InternalEObject, int, NotificationChain) line: 653
Comment 12 Sam Davis CLA 2013-08-19 17:26:43 EDT
(In reply to comment #8)
> Sam, regarding comment 0, do you have "Link with Editor" mode enabled for the
> Review explorer? Or any other non-default settings applied? How do you open the
> explorer?

I don't think so. I use ctrl+3 to open and sometimes I just leave it open.
Comment 13 Tomasz Zarna CLA 2013-08-20 09:05:46 EDT
After some debugging I found out that the NPE happens each time in @ReviewExplorer.setReview@ when @reviewConsumer.removeObserver(reviewObserver);@ is called and the consumer for an @IReview@ (model object) is released. Releasing/disposing the consumer clears the repository field (see comment 8) causes the NPE the moment later.

I'm still not sure why this happens only in some cases, but I don't think this is worth investigating at the same time when Miles is working on bug 413480.
Comment 14 Tomasz Zarna CLA 2013-08-20 09:11:46 EDT
You don't want to see all the sysouts I used in comment 13, but at the same time I found: https://git.eclipse.org/r/#/c/15651/ , which doesn't help a bit in this case (it's just a clean-up).
Comment 15 Miles Parker CLA 2013-08-21 14:52:07 EDT
(In reply to comment #13)
> After some debugging I found out that the NPE happens each time in
> @ReviewExplorer.setReview@ when @reviewConsumer.removeObserver(reviewObserver);@
> is called and the consumer for an @IReview@ (model object) is released.
> Releasing/disposing the consumer clears the repository field (see comment 8)
> causes the NPE the moment later.

Yeah, nice detective work! This is what my intuition was about related bug (can't find the comment now..)
> I'm still not sure why this happens only in some cases, but I don't think this
> is worth investigating at the same time when Miles is working on bug 413480.

+1 :D

I'll follow up on bug 415490
Comment 16 Sam Davis CLA 2014-05-30 13:21:45 EDT
I just got a similar NPE when opening a review by clicking the link in the dialog that comes up after pushing to Gerrit. It looks like review.getRepository() is null. It happened every time I switched editors to that review and refreshing the review didn't help. After closing and reopening the review it works.

java.lang.NullPointerException
	at org.eclipse.mylyn.internal.reviews.ui.views.ReviewExplorer.setReview(ReviewExplorer.java:530)
	at org.eclipse.mylyn.internal.reviews.ui.views.ReviewExplorer$2.partActivated(ReviewExplorer.java:173)
	at org.eclipse.ui.internal.PartListenerList$1.run(PartListenerList.java:72)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.runtime.Platform.run(Platform.java:857)
	at org.eclipse.ui.internal.PartListenerList.fireEvent(PartListenerList.java:57)
	at org.eclipse.ui.internal.PartListenerList.firePartActivated(PartListenerList.java:70)
	at org.eclipse.ui.internal.PartService.firePartActivated(PartService.java:187)
	at org.eclipse.ui.internal.PartService.setActivePart(PartService.java:306)
	at org.eclipse.ui.internal.WorkbenchPagePartList.fireActivePartChanged(WorkbenchPagePartList.java:57)
	at org.eclipse.ui.internal.PartList.setActivePart(PartList.java:136)
	at org.eclipse.ui.internal.WorkbenchPage.setActivePart(WorkbenchPage.java:3649)
	at org.eclipse.ui.internal.WorkbenchPage.requestActivation(WorkbenchPage.java:3172)
	at org.eclipse.ui.internal.PartPane.requestActivation(PartPane.java:281)
	at org.eclipse.ui.internal.EditorPane.requestActivation(EditorPane.java:98)
	at org.eclipse.ui.internal.PartPane.setFocus(PartPane.java:327)
	at org.eclipse.ui.internal.EditorPane.setFocus(EditorPane.java:127)
	at org.eclipse.ui.internal.PartStack.presentationSelectionChanged(PartStack.java:837)
	at org.eclipse.ui.internal.PartStack.access$1(PartStack.java:823)
	at org.eclipse.ui.internal.PartStack$1.selectPart(PartStack.java:137)
	at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation$1.handleEvent(TabbedStackPresentation.java:133)
	at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.fireEvent(AbstractTabFolder.java:269)
	at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.fireEvent(AbstractTabFolder.java:278)
	at org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder.access$1(DefaultTabFolder.java:1)
	at org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder$2.handleEvent(DefaultTabFolder.java:88)
	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.Widget.sendEvent(Widget.java:1077)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:774)
	at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:2746)
	at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1433)
	at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:257)
	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:4169)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3758)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
	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:353)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
Comment 17 Miles Parker CLA 2014-12-23 19:13:52 EST
Seems to have been resolved by other changes, given that we haven't had any similar reports. Please re-open if you see this happen again.