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 249108 - NullPointerException at javax.swing.text.JTextComponent.getCaretPosition
Summary: NullPointerException at javax.swing.text.JTextComponent.getCaretPosition
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Completion & Templates (show other bugs)
Version: 8.1
Hardware: All All
: P2 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
: 248814 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-12-04 13:43 UTC by bfanger
Modified: 2015-02-07 05:40 UTC (History)
7 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 213792


Attachments
stacktrace (4.17 KB, text/plain)
2014-12-04 13:43 UTC, bfanger
Details
stacktrace (4.06 KB, text/plain)
2014-12-10 11:07 UTC, akobberup
Details
stacktrace (4.06 KB, text/plain)
2015-01-08 11:15 UTC, akobberup
Details
stacktrace (4.46 KB, text/plain)
2015-01-14 16:36 UTC, Jesse Glick
Details
stacktrace (4.27 KB, text/plain)
2015-01-22 16:21 UTC, markiewb
Details
stacktrace (4.06 KB, text/plain)
2015-02-04 12:46 UTC, akobberup
Details
stacktrace (4.23 KB, text/plain)
2015-02-06 08:54 UTC, Martin Fousek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bfanger 2014-12-04 13:43:31 UTC
Build: NetBeans IDE Dev (Build 201412040001)
VM: Java HotSpot(TM) 64-Bit Server VM, 25.25-b02, Java(TM) SE Runtime Environment, 1.8.0_25-b17
OS: Mac OS X

User Comments:
GUEST: editing java file

bfanger: Selected a piece of javascript and pressed <backspace> to delete the selection.




Stacktrace: 
java.lang.NullPointerException
   at javax.swing.text.JTextComponent.getCaretPosition(JTextComponent.java:1644)
   at org.netbeans.editor.Abbrev.isAbbrevDisabled(Abbrev.java:85)
   at org.netbeans.lib.editor.codetemplates.AbbrevDetection.isAbbrevDisabled(AbbrevDetection.java:317)
   at org.netbeans.lib.editor.codetemplates.AbbrevDetection.removeUpdate(AbbrevDetection.java:243)
   at org.openide.util.WeakListenerImpl$Document.removeUpdate(WeakListenerImpl.java:309)
   at org.netbeans.lib.editor.util.swing.PriorityDocumentListenerList.removeUpdate(PriorityDocumentListenerList.java:116)
Comment 1 bfanger 2014-12-04 13:43:33 UTC
Created attachment 150877 [details]
stacktrace
Comment 2 akobberup 2014-12-10 11:07:25 UTC
Created attachment 151005 [details]
stacktrace

Trying to edit file
Comment 3 Exceptions Reporter 2014-12-23 18:02:34 UTC
This bug already has 5 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=213792
Comment 4 akobberup 2015-01-08 11:15:17 UTC
Created attachment 151406 [details]
stacktrace

used "alt + left-arrow" to navigate to latest changed code (java)
Comment 5 Milutin Kristofic 2015-01-09 17:53:00 UTC
*** Bug 248814 has been marked as a duplicate of this bug. ***
Comment 6 Jesse Glick 2015-01-14 16:36:40 UTC
Created attachment 151510 [details]
stacktrace

Started editing a Java source file after a hiatus. As I typed, the document appeared with a bold tab (modified), but the new text did not appear, nor did the caret move. I closed the tab (Ctrl-W), agreeing to discard modifications, and reopened the file. Now it is behaving normally.
Comment 7 markiewb 2015-01-22 16:21:48 UTC
Created attachment 151623 [details]
stacktrace

Started CodeCompletion?
Comment 8 Exceptions Reporter 2015-01-22 16:21:52 UTC
This bug already has 20 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=213792
Comment 9 akobberup 2015-02-04 12:46:06 UTC
Created attachment 151814 [details]
stacktrace

TRied to delete line (ctrl+e)
Comment 10 Martin Fousek 2015-02-06 08:54:21 UTC
Created attachment 151850 [details]
stacktrace

NPE during duplication line using CTRL+SHIFT+arrow
Comment 11 Dusan Balek 2015-02-06 10:23:04 UTC
Seems like a JDK problem - JTextComponent's public method called from AWT EDT.
Workarounded in jet-main.

http://hg.netbeans.org/jet-main/rev/df3d807bf501
Comment 12 _ gtzabari 2015-02-06 19:24:04 UTC
Dusan,

The NPE is being thrown when caret is null. caret is only set by JTextComponent.setCaret().

Who invoking this method? Maybe there is a race condition between the method that invokes the setter and Abbrev.isAbbrevDisabled()?
Comment 13 Quality Engineering 2015-02-07 05:40:45 UTC
Integrated into 'main-silver', will be available in build *201502070001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/df3d807bf501
User: Dusan Balek <dbalek@netbeans.org>
Log: Issue #249108 - NullPointerException at javax.swing.text.JTextComponent.getCaretPosition - workarounded.