Bug 573323

Summary: NPE in JavaElementHyperlinkDetector.findEnumConstructorTarget
Product: [Eclipse Project] JDT Reporter: Andrey Loskutov <loskutov>
Component: UIAssignee: Kenneth Styrberg <kenneth>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jjohnstn, kenneth
Version: 4.20Keywords: regression
Target Milestone: 4.20 M3   
Hardware: PC   
OS: Linux   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=520976
https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/180138
https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=7d2151f9fb0f94dc270a2f7569139d047fa6ab86
Whiteboard:

Description Andrey Loskutov CLA 2021-05-03 12:07:36 EDT
Just saw 6 errors in the log today with 4.20.0.I20210502-1800.

I don't even used SDK to write, I only browsed some code.

Seem to be regression from bug 520976.

java.lang.NullPointerException
	at org.eclipse.jdt.internal.ui.javaeditor.JavaElementHyperlinkDetector.findEnumConstructorTarget(JavaElementHyperlinkDetector.java:305)
	at org.eclipse.jdt.internal.ui.javaeditor.JavaElementHyperlinkDetector.detectHyperlinks(JavaElementHyperlinkDetector.java:115)
	at org.eclipse.ui.texteditor.HyperlinkDetectorRegistry$HyperlinkDetectorDelegate.detectHyperlinks(HyperlinkDetectorRegistry.java:81)
	at org.eclipse.jface.text.hyperlink.HyperlinkManager.findHyperlinks(HyperlinkManager.java:289)
	at org.eclipse.jface.text.hyperlink.HyperlinkManager.findHyperlinks(HyperlinkManager.java:262)
	at org.eclipse.jface.text.hyperlink.HyperlinkManager.mouseMove(HyperlinkManager.java:457)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:216)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5879)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1427)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:5121)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4599)
Comment 1 Andrey Loskutov CLA 2021-05-03 12:08:54 EDT
@Kenneth, Jeff: could you please check?
Comment 2 Kenneth Styrberg CLA 2021-05-03 13:35:12 EDT
I cannot reproduce, but at that line there's a missing NP check on 

"... node.getParent() ..."

I'll add a fix for this, if Jeff doesn't have any other conclusion!
Comment 3 Eclipse Genie CLA 2021-05-03 13:41:07 EDT
New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/180138
Comment 4 Jeff Johnston CLA 2021-05-03 15:26:01 EDT
(In reply to Kenneth Styrberg from comment #2)
> I cannot reproduce, but at that line there's a missing NP check on 
> 
> "... node.getParent() ..."
> 
> I'll add a fix for this, if Jeff doesn't have any other conclusion!

No, your fix certainly seems the only possibility.
Comment 6 Jeff Johnston CLA 2021-05-04 17:21:21 EDT
Hi Andrey, can you try the next I-build with Kenneth's fix and verify that it solves the problem?
Comment 7 Andrey Loskutov CLA 2021-05-05 02:05:55 EDT
(In reply to Jeff Johnston from comment #6)
> Hi Andrey, can you try the next I-build with Kenneth's fix and verify that
> it solves the problem?

Sure, however I have no idea how to reproduce.
Comment 8 Jeff Johnston CLA 2021-05-05 11:11:12 EDT
(In reply to Andrey Loskutov from comment #7)
> (In reply to Jeff Johnston from comment #6)
> > Hi Andrey, can you try the next I-build with Kenneth's fix and verify that
> > it solves the problem?
> 
> Sure, however I have no idea how to reproduce.

Basically, just verifying you are no longer seeing anything in the error log with respect to the JavaElementHyperlinkDetector in your normal usage would be fine.
Comment 9 Andrey Loskutov CLA 2021-05-06 06:54:19 EDT
Let assume it's fixed now, nothing seen in the log so far. 
I usually do not hesitate to reopen bugs if I see the regression again :-)
Thanks for the fast fix.