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

Bug 258679

Summary: [Undo] NPE in OperationHistoryActionHandler$HistoryListener when deleting multiple unsaved Java editors
Product: [Eclipse Project] Platform Reporter: Markus Keller <markus.kell.r>
Component: UIAssignee: Susan McCourt <susan>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, frederic_fusier, jeffmcaffer, michschn, Olivier_Thomann, pwebster
Version: 3.5   
Target Milestone: 3.5 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed Fix none

Description Markus Keller CLA 2008-12-12 13:11:21 EST
Created attachment 120352 [details]
Proposed Fix

I20081211-1908

- open a .java file
- press Space
- open another .java file
- press Space

- select the files in the Package Explorer
- press Delete
- click 'OK' (confirm delete)
- click 'Continue' (confirm unsaved files warning)

=> NPE in log

A difference to 3.5M3 is that the notification now happens in the ModalContextThread, and not in the UI thread.

AFAICS, the problem is that the OperationHistoryActionHandler is already disposed when HistoryListener.historyNotification(..) gets called.


java.lang.NullPointerException
	at org.eclipse.ui.operations.OperationHistoryActionHandler$HistoryListener.historyNotification(OperationHistoryActionHandler.java:123)
	at org.eclipse.core.commands.operations.DefaultOperationHistory$2.run(DefaultOperationHistory.java:939)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.notifyListeners(DefaultOperationHistory.java:928)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.notifyDone(DefaultOperationHistory.java:1002)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.closeOperation(DefaultOperationHistory.java:1371)
	at org.eclipse.ltk.internal.core.refactoring.UndoManager2.changePerformed(UndoManager2.java:152)
	at org.eclipse.ltk.core.refactoring.PerformChangeOperation$1.run(PerformChangeOperation.java:267)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
	at org.eclipse.ltk.core.refactoring.PerformChangeOperation.executeChange(PerformChangeOperation.java:308)
	at org.eclipse.ltk.internal.ui.refactoring.UIPerformChangeOperation.executeChange(UIPerformChangeOperation.java:92)
	at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:220)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
	at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Comment 1 Paul Webster CLA 2009-02-23 09:09:16 EST
*** Bug 265290 has been marked as a duplicate of this bug. ***
Comment 2 Susan McCourt CLA 2009-03-06 19:39:55 EST
Fixed in HEAD >20090306.

Note:  I couldn't reproduce the NPE in the log on WinXP, Build id: I20090304-0834, following the steps described in comment #0.  I tried three times.

However I think the code is safer/cleaner/simpler, so I am releasing the change.  Markus, were you able to get this to happen every time or can you think of a reason why I was not able to reproduce?  
Comment 3 Paul Webster CLA 2009-03-08 21:11:08 EDT
*** Bug 267541 has been marked as a duplicate of this bug. ***
Comment 4 Susan McCourt CLA 2009-03-10 17:37:44 EDT
I "verified" on WinXP, I20090310-0100, that I never saw this NPE during test pass, however I was unable to make it happen in the first place.  Markus, do you feel you can verify this fix?
Comment 5 Dani Megert CLA 2009-03-12 05:45:55 EDT
I was able to reproduce the NPE using 3.5 M5 and verified that it is fixed in I20090312-0100.
Comment 6 Susan McCourt CLA 2009-03-12 11:02:48 EDT
thanks, Dani.