[jbosstools-issues] [JBoss JIRA] (JBIDE-10572) NullPointerException in ClassHyperlink

Viacheslav Kabanovich (JIRA) jira-events at lists.jboss.org
Wed Jan 11 18:11:21 EST 2012


    [ https://issues.jboss.org/browse/JBIDE-10572?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12655355#comment-12655355 ] 

Viacheslav Kabanovich commented on JBIDE-10572:
-----------------------------------------------

I have verified the stated case and it is ok.

However, I see a bigger problem that either should be resolved withing this issue or new issue should be created.
This case is not the only, when partitioner and hyperlink classes compute region separately, and sometimes with different logic. Even in this case after the fix, methods ClassHyperlink.getRegion(int) and XMLClassHyperlinkPartitioner.getRegion(IDocument, int) have different logic. Could the first reuse the second (it is public static)? Even it it can, it is not the best solution. By now we have many hyperlink detector implementations which parse document to find a typed region by offset and then create hyperlink object that has nothing to parse more, just execute open-on. But the old HyperlinkDetector does its job in two stages: (1) compute region and its type; (2) create hyperlink object by the type without passing to it the computed region. I do not think that it is hard to modify HyperlinkDetector logic so that region created by partitioner would not be lost, but passed to hyperlink object. After that each hyperlink implementation may be reviewed to decide can it just use that passed region or there is a good reason to compute it again.

Viktor, please consider if you would do this within this issue or we should create a new one?
                
> NullPointerException in ClassHyperlink
> --------------------------------------
>
>                 Key: JBIDE-10572
>                 URL: https://issues.jboss.org/browse/JBIDE-10572
>             Project: Tools (JBoss Tools)
>          Issue Type: Bug
>          Components: common/jst/core
>    Affects Versions: 3.3.0.M5
>            Reporter: Viacheslav Kabanovich
>            Assignee: Viacheslav Kabanovich
>             Fix For: 3.3.0.Beta1
>
>         Attachments: NPE.txt
>
>
> Now the exception can be obtained only in struts-config.xml, but faults in our code make it probable to appear more generally.
> EXECUTE: Create Struts KickStart project and open struts-config.xml
> EXECUTE: Create global exception
> {code}
>   <exception className="/pages/greeting.jsp" key="a" path="/greeting.do" type="b"/>
> {code}
> where 'className' is deliberately assigned to an existing page path instead of a class name.
> EXECUTE: Call open-on options over word 'greeting'
> ASSERT: Two options appear:
> 1) open class 'greeting.jsp'
> 2) Open '/struts/WebContent/pages/greeting.jsp' with JBoss Tools JSP Editor
> EXECUTE: Call open-on options over symbol '/'
> FAILURE: null pointer exception; two options may still appear:
> 1) empty label
> 2) Open '/struts/WebContent/pages/greeting.jsp' with JBoss Tools JSP Editor
> I see the cause of the exception in difference of algorithm computing class name region in classes XMLClassHyperlinkPartitioner and ClassHyperlink. Partitioner returns attribute value with trimmed white spaces ant quote symbols. So, even if open-on is invoked over '/', partitioner reports XML_CLASS region and instance of ClassHyperlink is created for it. But ClassHyperlink computes region more strictly, so that text contains only qualified Java name symbols. When open-on is invoked over '/', ClassHyperlink sets region to open to null. If there is no other hyperlink option, that may pass, but when several hyperlinks are detected, MultipleHyperlinkPresenter requests each for hyperlink text, and ClassHyperlink fails. In this case the other option is WST's WorkspaceFileHyperlink, it detects in any attribute values resource paths; if it starts to detect them in text nodes (and why not?), this issue will take place in faces-config.xml and web.xml, where class names are assigned as text nodes.
> This issue cannot be fixed just by preventing NPE, because open-on option with empty label may appear all the same. Solution is to let partitioner report a region for a corresponding hyperlink only when the hyperlink accepts that region as relevant.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the jbosstools-issues mailing list