This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 219520 - NullPointerException at org.netbeans.modules.csl.api.InstantRenameAction$1.run
Summary: NullPointerException at org.netbeans.modules.csl.api.InstantRenameAction$1.run
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: CSL (API & infrastructure) (show other bugs)
Version: 7.3
Hardware: All All
: P3 normal (vote)
Assignee: Milutin Kristofic
URL:
Keywords:
Depends on:
Blocks: 219432
  Show dependency tree
 
Reported: 2012-10-04 12:29 UTC by Sergey Petrov
Modified: 2012-10-12 02:08 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 183156


Attachments
stacktrace (3.88 KB, text/plain)
2012-10-04 12:29 UTC, Sergey Petrov
Details
stacktrace (3.90 KB, text/plain)
2012-10-05 09:50 UTC, Sergey Petrov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sergey Petrov 2012-10-04 12:29:47 UTC
Build: NetBeans IDE Dev (Build 20120924-33dc4b5c0263)
VM: Java HotSpot(TM) Client VM, 22.1-b02, Java(TM) SE Runtime Environment, 1.7.0_03-b05
OS: Windows 7

User Comments:
GUEST: Executing SQL statement

sj-nb: ctrl-r in SQL editor

dagguh: I opened a shell script with PHP as a PHP file and tried to rename a variable




Stacktrace: 
java.lang.NullPointerException
   at org.netbeans.modules.csl.api.InstantRenameAction$1.run(InstantRenameAction.java:128)
   at org.netbeans.modules.parsing.impl.TaskProcessor.callUserTask(TaskProcessor.java:583)
   at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:150)
   at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:134)
   at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:200)
   at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:197)
Comment 1 Sergey Petrov 2012-10-04 12:29:49 UTC
Created attachment 125380 [details]
stacktrace
Comment 2 Sergey Petrov 2012-10-04 12:33:31 UTC
it may have the same reason as issue 219432.
the question is if csl api need to handle such cases or api users should do/implement something to avoid these exceptions
Comment 3 Sergey Petrov 2012-10-04 12:54:59 UTC
it may matter: sql editor was invoked for a connection on services tab.
Comment 4 Milutin Kristofic 2012-10-04 13:54:11 UTC
http://hg.netbeans.org/jet-main/rev/8e1bf7c1bee4
Comment 5 Quality Engineering 2012-10-05 02:03:21 UTC
Integrated into 'main-golden', will be available in build *201210050002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/8e1bf7c1bee4
User: Milutin Kristofic <mkristofic@netbeans.org>
Log: #219520 - NullPointerException at org.netbeans.modules.csl.api.InstantRenameAction$1.run
Comment 6 Sergey Petrov 2012-10-05 09:50:13 UTC
Created attachment 125436 [details]
stacktrace

ctrl-r in jqpl editor
Comment 7 Sergey Petrov 2012-10-05 09:50:28 UTC
after  	219432  fix I have the same exception (but on line 129 now) in both sql and jpql editors.
Comment 8 Milutin Kristofic 2012-10-05 14:28:37 UTC
Ok, I was checking if resultIterator can be null. My next candidate is parserresult.
Comment 9 Milutin Kristofic 2012-10-08 15:38:39 UTC
Sergey, does jpgl has parser? ResultIterator doesn't have its parser, therefore parserResult is empty and throws null. I can check null and do nothing, or you can give a parser to resultIterator and enable rename refactor.
Comment 10 Sergey Petrov 2012-10-09 06:46:20 UTC
cc jrechtacek@netbeans.org for sql editor.

regarding jpql, I'm not sure I use api properly, it was design at some minimum level for this release, what do you mean by parser? Currently I have lexer skeleton with minimum functionality, also content is parsed by cc but it's entirely in jpql cc area.
Regarding functionality itself, I don't refactor rename as really useful for jpql editor so far and likely in terms of parser which can be used in refactor rename there is no plan to support it at least in 7.3
Comment 11 Milutin Kristofic 2012-10-09 12:31:59 UTC
Your JPQLLanguage in org.netbeans.modules.j2ee.persistence.jpqleditor.lexer extends DefaultLanguageConfig. DefaultLanguageConfig has method getParser() and it returns always null.

Therefore when SourceCache in org.netbeans.modules.parsing.impl calls getParser() method [1] where it uses lookup for your jpql mimetype, the parseFactory create null parser. This nullparser creates null parserResult and throws nullpointer exception in InstantRenameAction.

[1]
Lookup lookup = MimeLookup.getLookup (mimeType);
        ParserFactory parserFactory = lookup.lookup (ParserFactory.class);
        if (parserFactory != null) {
            final Snapshot _snapshot = getSnapshot ();
            final Collection<Snapshot> _tmp = Collections.singleton (_snapshot);
            _parser = parserFactory.createParser (_tmp);
        }


So you can override getParser() in JPQLLanguage and implement simple parser.

Or I can check null value and throw warning.
Comment 12 Sergey Petrov 2012-10-10 06:50:56 UTC
It's nice if you can just check for null for now
Comment 13 Milutin Kristofic 2012-10-10 15:16:50 UTC
http://hg.netbeans.org/jet-main/rev/5883ac8f78eb
Comment 14 Quality Engineering 2012-10-12 02:08:09 UTC
Integrated into 'main-golden', will be available in build *201210120002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/5883ac8f78eb
User: Milutin Kristofic <mkristofic@netbeans.org>
Log: #219520 - NullPointerException at org.netbeans.modules.csl.api.InstantRenameAction$1.run