Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 300157 - [compare] NPE while opening compare editor
Summary: [compare] NPE while opening compare editor
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.6   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.6 M6   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-20 05:18 EST by Benjamin Muskalla CLA
Modified: 2010-03-09 03:43 EST (History)
3 users (show)

See Also:


Attachments
complete error log (1002.51 KB, application/octet-stream)
2010-01-20 06:45 EST, Deepak Azad CLA
no flags Details
error log (158.22 KB, text/plain)
2010-01-20 09:51 EST, Deepak Azad CLA
no flags Details
fix (992 bytes, patch)
2010-02-23 16:35 EST, Deepak Azad CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Muskalla CLA 2010-01-20 05:18:14 EST
-- Error Details --
Date: Wed Jan 20 11:14:32 CET 2010
Message: Problems occurred when invoking code from plug-in: "org.eclipse.ui.workbench".
Severity: Error
Product: Eclipse SDK 3.6.0.v201001120800 (org.eclipse.sdk.ide)
Plugin: org.eclipse.ui.workbench
Session Data:
eclipse.buildId=I20100112-0800
java.version=1.6.0_16
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US
Framework arguments:  -server
Command-line arguments:  -os linux -ws gtk -arch x86 -server


Happend as I opened a compare editor, NPE was thrown about 50 times. Had 5 other java files open in the meantime.

Exception Stack Trace:
java.lang.NullPointerException
	at org.eclipse.ui.texteditor.AbstractTextEditor$ActivationListener.windowActivated(AbstractTextEditor.java:994)
	at org.eclipse.ui.internal.Workbench$12.run(Workbench.java:823)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.Workbench.fireWindowActivated(Workbench.java:821)
	at org.eclipse.ui.internal.WorkbenchWindow$28.shellActivated(WorkbenchWindow.java:3089)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:82)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1218)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1242)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1223)
	at org.eclipse.swt.widgets.Shell.filterProc(Shell.java:728)
	at org.eclipse.swt.widgets.Display.filterProc(Display.java:1516)
	at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
	at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:2132)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3129)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2407)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2371)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2220)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
	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:367)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:611)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:566)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1363)
Comment 1 Dani Megert CLA 2010-01-20 05:25:38 EST
This looks like a follow up problem. Can you post the whole .log please.
Comment 2 Benjamin Muskalla CLA 2010-01-20 05:31:45 EST
No other errors since starting that workbench instance. The only thing that happend several seconds before the first NPE were some handler conflicts:

!ENTRY org.eclipse.ui.workbench 2 0 2010-01-20 11:09:33.201
!MESSAGE A handler conflict occurred.  This may disable some commands.
!SUBENTRY 1 org.eclipse.ui.workbench 2 0 2010-01-20 11:09:33.201
!MESSAGE Conflict for 'org.eclipse.compare.copyAllRightToLeft':
HandlerActivation(commandId=org.eclipse.compare.copyAllRightToLeft,
	handler=ActionHandler(org.eclipse.compare.contentmergeviewer.ContentMergeViewer$9@11dc534),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@11261bd),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@8ca8ac)),sourcePriority=1064960)
HandlerActivation(commandId=org.eclipse.compare.copyAllRightToLeft,
	handler=ActionHandler(org.eclipse.compare.contentmergeviewer.ContentMergeViewer$9@17e0bc2),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@11261bd),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@8ca8ac)),sourcePriority=1064960)
!SUBENTRY 1 org.eclipse.ui.workbench 2 0 2010-01-20 11:09:33.201
!MESSAGE Conflict for 'org.eclipse.compare.selectPreviousChange':
HandlerActivation(commandId=org.eclipse.compare.selectPreviousChange,
	handler=ActionHandler(org.eclipse.compare.contentmergeviewer.TextMergeViewer$36@360a04),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@11261bd),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@8ca8ac)),sourcePriority=1064960)
HandlerActivation(commandId=org.eclipse.compare.selectPreviousChange,
	handler=ActionHandler(org.eclipse.compare.contentmergeviewer.TextMergeViewer$36@1cba763),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@11261bd),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@8ca8ac)),sourcePriority=1064960)
!SUBENTRY 1 org.eclipse.ui.workbench 2 0 2010-01-20 11:09:33.201
!MESSAGE Conflict for 'org.eclipse.ui.editors.lineNumberToggle':
HandlerActivation(commandId=org.eclipse.ui.editors.lineNumberToggle,
	handler=ActionHandler(org.eclipse.compare.internal.TextEditorPropertyAction@15a7968),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@11261bd),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@8ca8ac)),sourcePriority=1064960)
HandlerActivation(commandId=org.eclipse.ui.editors.lineNumberToggle,
	handler=ActionHandler(org.eclipse.compare.internal.TextEditorPropertyAction@d8a0aa),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@11261bd),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@8ca8ac)),sourcePriority=1064960)
!SUBENTRY 1 org.eclipse.ui.workbench 2 0 2010-01-20 11:09:33.201
!MESSAGE Conflict for 'org.eclipse.compare.ignoreWhiteSpace':
HandlerActivation(commandId=org.eclipse.compare.ignoreWhiteSpace,
	handler=ActionHandler(org.eclipse.compare.internal.ChangePropertyAction@1c2a92),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@11261bd),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@8ca8ac)),sourcePriority=1064960)
HandlerActivation(commandId=org.eclipse.compare.ignoreWhiteSpace,
	handler=ActionHandler(org.eclipse.compare.internal.ChangePropertyAction@12eeee4),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@11261bd),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@8ca8ac)),sourcePriority=1064960)
!SUBENTRY 1 org.eclipse.ui.workbench 2 0 2010-01-20 11:09:33.201
!MESSAGE Conflict for 'org.eclipse.ui.edit.text.toggleShowWhitespaceCharacters':
HandlerActivation(commandId=org.eclipse.ui.edit.text.toggleShowWhitespaceCharacters,
	handler=ActionHandler(org.eclipse.compare.internal.ShowWhitespaceAction@45d917),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@11261bd),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@8ca8ac)),sourcePriority=1064960)
HandlerActivation(commandId=org.eclipse.ui.edit.text.toggleShowWhitespaceCharacters,
	handler=ActionHandler(org.eclipse.compare.internal.ShowWhitespaceAction@1af7838),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@11261bd),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@8ca8ac)),sourcePriority=1064960)
!SUBENTRY 1 org.eclipse.ui.workbench 2 0 2010-01-20 11:09:33.201
!MESSAGE Conflict for 'org.eclipse.compare.copyRightToLeft':
HandlerActivation(commandId=org.eclipse.compare.copyRightToLeft,
	handler=ActionHandler(org.eclipse.compare.contentmergeviewer.TextMergeViewer$38@fdcf74),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@11261bd),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@8ca8ac)),sourcePriority=1064960)
HandlerActivation(commandId=org.eclipse.compare.copyRightToLeft,
	handler=ActionHandler(org.eclipse.compare.contentmergeviewer.TextMergeViewer$38@13edba5),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@11261bd),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@8ca8ac)),sourcePriority=1064960)
!SUBENTRY 1 org.eclipse.ui.workbench 2 0 2010-01-20 11:09:33.201
!MESSAGE Conflict for 'org.eclipse.compare.selectNextChange':
HandlerActivation(commandId=org.eclipse.compare.selectNextChange,
	handler=ActionHandler(org.eclipse.compare.contentmergeviewer.TextMergeViewer$35@1c63782),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@11261bd),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@8ca8ac)),sourcePriority=1064960)
HandlerActivation(commandId=org.eclipse.compare.selectNextChange,
	handler=ActionHandler(org.eclipse.compare.contentmergeviewer.TextMergeViewer$35@6639bd),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@11261bd),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@8ca8ac)),sourcePriority=1064960)

And after that, hundrets of that NPE happend
Comment 3 Dani Megert CLA 2010-01-20 05:35:55 EST
The handler thing looks suspicious too. Is this plain Eclipse SDK? Can you reproduce? Otherwise there's not much we can do here.
Comment 4 Benjamin Muskalla CLA 2010-01-20 05:51:09 EST
Plain SDK + Mylyn and no, cannot reproduce :(
Feel free to close it if you don't have an idea what's going on here :/
Comment 5 Deepak Azad CLA 2010-01-20 06:21:40 EST
I saw an NPE in compare editorsyesterday with I20100112-0800. Will try to reproduce it and provide more info.
Comment 6 Deepak Azad CLA 2010-01-20 06:43:39 EST
I see this in my yesterday's log of eclipse. (This is a different command than comment 2)

!ENTRY org.eclipse.ui.workbench 2 0 2010-01-19 17:05:01.703
!MESSAGE A handler conflict occurred.  This may disable some commands.
!SUBENTRY 1 org.eclipse.ui.workbench 2 0 2010-01-19 17:05:01.703
!MESSAGE Conflict for 'org.eclipse.compare.selectNextChange':
HandlerActivation(commandId=org.eclipse.compare.selectNextChange,
	handler=ActionHandler(org.eclipse.compare.contentmergeviewer.TextMergeViewer$35@611a611a),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@25d825d8),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@297a297a)),sourcePriority=1064960)
HandlerActivation(commandId=org.eclipse.compare.selectNextChange,
	handler=ActionHandler(org.eclipse.compare.contentmergeviewer.TextMergeViewer$35@7b867b86),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@25d825d8),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@297a297a)),sourcePriority=1064960)
!SUBENTRY 1 org.eclipse.ui.workbench 2 0 2010-01-19 17:05:01.703
!MESSAGE Conflict for 'org.eclipse.compare.copyRightToLeft':
HandlerActivation(commandId=org.eclipse.compare.copyRightToLeft,
	handler=ActionHandler(org.eclipse.compare.contentmergeviewer.TextMergeViewer$38@73de73de),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@25d825d8),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@297a297a)),sourcePriority=1064960)
HandlerActivation(commandId=org.eclipse.compare.copyRightToLeft,
	handler=ActionHandler(org.eclipse.compare.contentmergeviewer.TextMergeViewer$38@eda0eda),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@25d825d8),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@297a297a)),sourcePriority=1064960)
!SUBENTRY 1 org.eclipse.ui.workbench 2 0 2010-01-19 17:05:01.703
!MESSAGE Conflict for 'org.eclipse.ui.edit.text.toggleShowWhitespaceCharacters':
HandlerActivation(commandId=org.eclipse.ui.edit.text.toggleShowWhitespaceCharacters,
	handler=ActionHandler(org.eclipse.compare.internal.ShowWhitespaceAction@22282228),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@25d825d8),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@297a297a)),sourcePriority=1064960)
HandlerActivation(commandId=org.eclipse.ui.edit.text.toggleShowWhitespaceCharacters,
	handler=ActionHandler(org.eclipse.compare.internal.ShowWhitespaceAction@6080608),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@25d825d8),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@297a297a)),sourcePriority=1064960)
!SUBENTRY 1 org.eclipse.ui.workbench 2 0 2010-01-19 17:05:01.703
!MESSAGE Conflict for 'org.eclipse.compare.ignoreWhiteSpace':
HandlerActivation(commandId=org.eclipse.compare.ignoreWhiteSpace,
	handler=ActionHandler(org.eclipse.compare.internal.ChangePropertyAction@188e188e),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@25d825d8),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@297a297a)),sourcePriority=1064960)
HandlerActivation(commandId=org.eclipse.compare.ignoreWhiteSpace,
	handler=ActionHandler(org.eclipse.compare.internal.ChangePropertyAction@7d4a7d4a),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@25d825d8),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@297a297a)),sourcePriority=1064960)
!SUBENTRY 1 org.eclipse.ui.workbench 2 0 2010-01-19 17:05:01.703
!MESSAGE Conflict for 'org.eclipse.ui.editors.lineNumberToggle':
HandlerActivation(commandId=org.eclipse.ui.editors.lineNumberToggle,
	handler=ActionHandler(org.eclipse.compare.internal.TextEditorPropertyAction@24e424e4),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@25d825d8),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@297a297a)),sourcePriority=1064960)
HandlerActivation(commandId=org.eclipse.ui.editors.lineNumberToggle,
	handler=ActionHandler(org.eclipse.compare.internal.TextEditorPropertyAction@8320832),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@25d825d8),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@297a297a)),sourcePriority=1064960)
!SUBENTRY 1 org.eclipse.ui.workbench 2 0 2010-01-19 17:05:01.703
!MESSAGE Conflict for 'org.eclipse.compare.selectPreviousChange':
HandlerActivation(commandId=org.eclipse.compare.selectPreviousChange,
	handler=ActionHandler(org.eclipse.compare.contentmergeviewer.TextMergeViewer$36@6a726a72),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@25d825d8),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@297a297a)),sourcePriority=1064960)
HandlerActivation(commandId=org.eclipse.compare.selectPreviousChange,
	handler=ActionHandler(org.eclipse.compare.contentmergeviewer.TextMergeViewer$36@5260526),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@25d825d8),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@297a297a)),sourcePriority=1064960)
!SUBENTRY 1 org.eclipse.ui.workbench 2 0 2010-01-19 17:05:01.703
!MESSAGE Conflict for 'org.eclipse.compare.copyAllRightToLeft':
HandlerActivation(commandId=org.eclipse.compare.copyAllRightToLeft,
	handler=ActionHandler(org.eclipse.compare.contentmergeviewer.ContentMergeViewer$9@4e464e46),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@25d825d8),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@297a297a)),sourcePriority=1064960)
HandlerActivation(commandId=org.eclipse.compare.copyAllRightToLeft,
	handler=ActionHandler(org.eclipse.compare.contentmergeviewer.ContentMergeViewer$9@34ca34ca),
	expression=AndExpression(ActivePartExpression(org.eclipse.compare.internal.CompareEditor@25d825d8),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow@297a297a)),sourcePriority=1064960)
Comment 7 Deepak Azad CLA 2010-01-20 06:45:24 EST
Created attachment 156623 [details]
complete error log
Comment 8 Deepak Azad CLA 2010-01-20 06:54:04 EST
I am unable to reproduce it now. I think I saw this in Team Synchronizing perspective when there were both incoming and outgoing changes (right now I have only outgoing changes). The exception happened as I was clicking the 'Next Difference' Icon.

Also I have plain eclipse sdk, there are no extra plugins.
Comment 9 Deepak Azad CLA 2010-01-20 09:51:21 EST
Created attachment 156650 [details]
error log

Got this error again, but the cause looks to be different.
Comment 10 Dani Megert CLA 2010-01-28 04:13:03 EST
Sorry, but cannot reproduce using I20100127-1800.
Please reopen if you can provide steps.
Comment 11 Deepak Azad CLA 2010-02-23 16:35:17 EST
Created attachment 159999 [details]
fix

I have this habit of clicking on 'Next Difference' icon in the 'Synchronize' view multiple times very fast to open all the files that have changed (since there is no expand all button). When the number of changed files are about 10 I get this NPE and at times I need to restart Eclipse to get rid of the NPE error dialog (quite annoying).

The patch fixes the problem (there is no NPE). Javadoc for getEditorSite() (called at org.eclipse.ui.texteditor.AbstractTextEditor$ActivationListener.windowActivated(AbstractTextEditor.java:994)
) says 'The site can be null while the editor is being initialized.' so i guess that was the problem, I click too fast for the editor to be initialized ;-).

The problem can be reproduced with I20100217-1031.

PS: Dani, I dont have rights to reopen the bug.
Comment 12 Dani Megert CLA 2010-02-24 04:20:53 EST
> (since there is no expand all button).
On windows you can press the [x] numpad button.

>The problem can be reproduced with I20100217-1031.
Sorry but I can't. I opened the Synchronize view with many changes and then kept pressing Ctrl+. to go to the next difference which opened all compare editors. Please try to provide reproducible steps that start with a new workspace.

The proposed fix just puts a band-aid at the wrong place without understanding the real problem behind the bug (i.e. why is the site null there?). I rather suspect a workflow issue in the compare editor but as said before: hard to tell without steps.
Comment 13 Deepak Azad CLA 2010-02-24 10:24:22 EST
(In reply to comment #12)
> > (since there is no expand all button).
> On windows you can press the [x] numpad button.
> 
> >The problem can be reproduced with I20100217-1031.
> Sorry but I can't. I opened the Synchronize view with many changes and then
> kept pressing Ctrl+. to go to the next difference which opened all compare
> editors. Please try to provide reproducible steps that start with a new
> workspace.
Can you try by clicking the 'Next Difference' button very fast instead of using the keyboard. Even I have not been able to reproduce by pressing 'Ctrl+.'. Is there a difference in both implementations? Possibly. Using 'Ctrl+.' shows a 'You have reached the last difference' dialog but Mouse clicks on the button do not bring up such a dialog.(I have not seen the code at this point)
(I know that the bug may be a bit tricky to reproduce, but I am spending time on this because it has annoyed me enough)

> The proposed fix just puts a band-aid at the wrong place without understanding
> the real problem behind the bug (i.e. why is the site null there?). I rather
> suspect a workflow issue in the compare editor but as said before: hard to tell
> without steps.
Javadoc for org.eclipse.ui.IEditorPart.getEditorSite() says "The site can be <code>null</code> while the editor is being initialized.". So I think that there can be cases when we have to do a null check. However I could find only one such instance org.eclipse.jdt.internal.ui.propertiesfileeditor.PropertiesFileEditor.updateStatusField(String). In other places there was no null check.

Also on some occasions (very rare) the NPE happens at a different place (at a org.eclipse.ui.IWorkbenchPart.getSite() invokation)
java.lang.NullPointerException
	at org.eclipse.jdt.internal.ui.text.JavaReconciler.uninstall(JavaReconciler.java:341)
	at org.eclipse.jface.text.source.SourceViewer.unconfigure(SourceViewer.java:692)
	at org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer.unconfigure(JavaSourceViewer.java:357)
	at org.eclipse.jface.text.source.SourceViewer.handleDispose(SourceViewer.java:745)

Doing a null check may not be the best solution, but in my opinion it is much better than throwing NPEs and on occasions making the user to restart eclipse.
Comment 14 Dani Megert CLA 2010-02-24 10:50:52 EST
>Can you try by clicking the 'Next Difference' button very fast instead of using
>the keyboard.
I tried that first and then hoped the keyboard way is faster and surfaces the problem even more. Did you try with a new workspace? Settings do affect what happens (e.g. whether compare editor is reused). As said before, please provide steps that start with a fresh workspace. If I then still can't reproduce then you'd have to debug the issue in your workspace.

>So I think that
>there can be cases when we have to do a null check.
At the time the window listener is installed, the site is not null and hence if it is null later then that's a life-cycle bug somewhere else.

>Doing a null check may not be the best solution, but in my opinion it is much
>better than throwing NPEs and on occasions making the user to restart eclipse.
Well, you cannot be sure of that if you don't know the real cause of the problem, maybe at a later point that real problem erases your hard disk, so you'd better try to find out the real cause instead of hiding it forever with a null check ;-)
Comment 15 Deepak Azad CLA 2010-02-24 12:34:45 EST
(In reply to comment #14)
> >Can you try by clicking the 'Next Difference' button very fast instead of using
> >the keyboard.
> I tried that first and then hoped the keyboard way is faster and surfaces the
> problem even more. Did you try with a new workspace? Settings do affect what
> happens (e.g. whether compare editor is reused). As said before, please provide
> steps that start with a fresh workspace. If I then still can't reproduce then
> you'd have to debug the issue in your workspace.
Yes, I did try with new workspace as well.
1. Start eclipse with a new workspace
2. Check out org.eclipse.jface.text (anything else also would be fine)
3. Change 15 files, one change per file. (I just inserted about 5 new lines in one comment in each file)
4. Synchronize with repository
5. Click 'Next Difference' multiple times very fast -> NPEs
Yes, the Compare editor is reused. (plus all the default settings with a new workspace)

If the compare editor is NOT reused then things seem to work fine.
> 
> >So I think that
> >there can be cases when we have to do a null check.
> At the time the window listener is installed, the site is not null and hence if
> it is null later then that's a life-cycle bug somewhere else.
Maybe the site is set to null for the next file but some processing is still going on for the first file.
 
> >Doing a null check may not be the best solution, but in my opinion it is much
> >better than throwing NPEs and on occasions making the user to restart eclipse.
> Well, you cannot be sure of that if you don't know the real cause of the
> problem, maybe at a later point that real problem erases your hard disk, so
> you'd better try to find out the real cause instead of hiding it forever with a
> null check ;-)
hmmm..
Comment 16 Dani Megert CLA 2010-02-24 12:37:27 EST
>If the compare editor is NOT reused then things seem to work fine.
OK, that's definitely a difference to my setup. I'll give it another try tomorrow.
Comment 17 Dani Megert CLA 2010-02-25 09:46:19 EST
General > 'Always run in background' must be disabled (default).

As expected the bug is not in Text but in Java compare: they have an  additional dispose path and when the progress dialog is up it spins the event loop as a result sometimes the merge viewer and the editor don't get disposed in the expected sequence. As a consequence the CompareEditorInput.fContainer is null'ed out before the editor's window listener is removed, however, that container is used to fetch the site when the window gets the focus back by clicking the Next Diff button. I've fixed that hole but most likely you'll see other strange things when clicking fast, like e.g. bug 272953.
Comment 18 Deepak Azad CLA 2010-03-09 01:54:59 EST
Thanks! Even after clicking very very fast I cannot reproduce this :).

Verified with I20100308-1300 for 3.6 M6.
Comment 19 Deepak Azad CLA 2010-03-09 03:43:58 EST
The NPE from comment 0 is fixed and now no blocking dialog pops up but still there are exceptions in the error log. Filed Bug 305113 for those.