[YANGIDE-15] Sometimes get NPE in HelpCompositionUtils.getNodeHelp(ASTNode) Created: 16/May/16  Updated: 03/Jun/16  Resolved: 03/Jun/16

Status: Resolved
Project: yangide
Component/s: General
Affects Version/s: unspecified
Fix Version/s: None

Type: Bug
Reporter: David M. Karr Assignee: Dhevendran Kulandaivel
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 5891

 Description   

I sometimes see the following stacktrace:

Exception:java.lang.NullPointerException: null
at org.opendaylight.yangide.editor.editors.text.help.HelpCompositionUtils.getNodeHelp(HelpCompositionUtils.java:50)
at org.opendaylight.yangide.editor.editors.text.hover.YangTextHover.getHoverInfo(YangTextHover.java:71)
at org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:168)

Besides the error dialog, I don't see any consequences from it.

Here's the "getNodeHelp" method:
------------
public static String getNodeHelp(ASTNode node) {
if (node.getDescription() != null && node.getDescription().length() > 0)

{ // line 50. return getLocalInfo(node); }

String info = getIndexedInfo(node);
if (info == null)
info = getLanguageHelp(node);
return info;
}
-------------

From the context of line 50, it appears that "node" is null. I don't think I've ever seen this happen when I had the debugger connected and a breakpoint enabled here. I've tried to connect up the debugger after I see this happen, but I've never been able to repeat it when the debugger is connected.

A simple fix could be to just return null if node is null. It appears from inspecting the "TextViewerHoverManager" code that calls this indirectly, that it would deal smoothly with a null return value.

However, it's not clear whether getting a null value here is an indication of something else going wrong.



 Comments   
Comment by Dhevendran Kulandaivel [ 02/Jun/16 ]

Hi David M. Karr

The fix is available in https://git.opendaylight.org/gerrit/#/c/39743/

Thanks & Regards,
Dhevendran K

Comment by David M. Karr [ 02/Jun/16 ]

Were you able to figure out how to repeat this reliably? I would have fixed this myself, but I wanted to understand why this was happening, or at least be able to repeat it.

Comment by Dhevendran Kulandaivel [ 02/Jun/16 ]

(In reply to David M. Karr from comment #2)
> Were you able to figure out how to repeat this reliably? I would have fixed
> this myself, but I wanted to understand why this was happening, or at least
> be able to repeat it.

Hi David M. Karr

Thanks for your comment.
No, I do not have the procedure to repeat / test the same. But, as far as the implementation goes, the null check is missing. Hence, it has been corrected

Comment by David M. Karr [ 02/Jun/16 ]

The change for this has been merged. I suppose we can mark it resolved, but it's a little annoying to mark a bug resolved that I don't even know how to test for.

Comment by Dhevendran Kulandaivel [ 03/Jun/16 ]

Hi David M. Karr

This can be marked it as resolved since we are pretty sure ( in the implementation angel) that the exception is due to lack of null check at line number 50 in old code (i.e. 52 in merged code)

Let us see whether this occurs in any of the product testing since we do not have any definite reproducer

Thanks & Regards,
Dhevendran K

Generated at Wed Feb 07 20:48:27 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.