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 176777

Summary: [68cat] NullPointerException at org.netbeans.lib.editor.util.swing.DocumentUtilities.addPriorityDocumentListener
Product: contrib Reporter: misterm <misterm>
Component: CodeAssignee: Michel Graciano <hmichel>
Status: VERIFIED FIXED    
Severity: normal CC: hmichel, jkovalsky
Priority: P3 Keywords: NETFIX
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter: 153007
Attachments: stacktrace
NBM package with fix
Small patch

Description misterm 2009-11-13 05:18:24 UTC
Build: NetBeans IDE Dev (Build 091110-2ed0c0f492b5)
VM: Java HotSpot(TM) Client VM, 10.0-b19, Java(TM) SE Runtime Environment, 1.6.0_04-b12
OS: Windows XP, 5.1, x86

Stacktrace: 
java.lang.NullPointerException
        at org.netbeans.lib.editor.util.swing.DocumentUtilities.addPriorityDocumentListener(DocumentUtilities.java:127)
        at org.netbeans.lib.editor.util.swing.DocumentUtilities.addDocumentListener(DocumentUtilities.java:105)
        at org.netbeans.modules.showtodos.TodoAnnotationProvider$ScanningListener.attachTo(TodoAnnotationProvider.java:164)
        at org.netbeans.modules.showtodos.TodoAnnotationProvider$ScanningListener.attachTo(TodoAnnotationProvider.java:173)
        at org.netbeans.modules.showtodos.TodoAnnotationProvider$ScanningListener.access$000(TodoAnnotationProvider.java:136)
        at org.netbeans.modules.showtodos.TodoAnnotationProvider.annotate(TodoAnnotationProvider.java:92)
Comment 1 misterm 2009-11-13 05:18:28 UTC
Created attachment 90984 [details]
stacktrace
Comment 2 Vitezslav Stejskal 2009-11-13 05:59:32 UTC
org.netbeans.modules.showtodos.TodoAnnotationProvider$ScanningListener.attachTo(TodoAnnotationProvider.java:164)
Comment 3 Jiri Kovalsky 2010-04-08 11:06:39 UTC
Issue added to NetFIX Pool [1]. Module owner please speak up if you disagree.

[1] http://wiki.netbeans.org/NetFIXIssues

For NetFIX developers, the class is located in this package:

http://hg.netbeans.org/main/contrib/file/tip/showtodos/src/org/netbeans/modules/showtodos
Comment 4 ehartmann 2010-04-08 12:51:03 UTC
I used a lot ShowTodos module, I've never seen this exception.

From the exception stack trace, it seems that either there is no EditorCookie from the context, or ck.openDocument() is null. That seems strange.

Here is a small patch that should prevent this exception by testing the existence of an EditorCookie from the context.

Misterm, can you provide me a scenario for testing my patch ?

-éric
Comment 5 misterm 2010-04-08 13:08:43 UTC
It was random, sorry.
Comment 6 ehartmann 2010-04-08 13:13:30 UTC
Created attachment 96890 [details]
NBM package with fix
Comment 7 ehartmann 2010-04-08 13:14:47 UTC
Misterm,

I've attached a nbm package build today with my fix, can you upgrade your version with this one (I've bumped the version, so it should install without trouble), and tell me if the exception is gone ?

Thanks for your help

-éric
Comment 8 ehartmann 2010-04-08 13:57:30 UTC
Created attachment 96894 [details]
Small patch
Comment 9 Jiri Kovalsky 2010-04-08 14:03:28 UTC
Michel, could you please review the patch and integrate it if you don't have objections? Thanks!
Comment 10 Michel Graciano 2010-04-08 14:14:01 UTC
I will review it soon. I am glad to see patch coming for this module :)
Comment 11 Michel Graciano 2010-04-08 14:48:01 UTC
@Michael, do you remember which kind of file was you editing in that time? :)
Comment 12 Michel Graciano 2010-04-08 14:52:19 UTC
Changeset: 870582a9a83c
Author:    Michel Graciano <hmichel@netbeans.org>
Date:      2010-04-08 11:50
Message:   Bug #176777 - [68cat] NullPointerException at org.netbeans.lib.editor.util.swing.DocumentUtilities.addPriorityDocumentListener
Issue #176777 - [68cat] NullPointerException at org.netbeans.lib.editor.util.swing.DocumentUtilities.addPriorityDocumentListener
Comment 13 Michel Graciano 2010-04-08 14:55:23 UTC
Thanks Eric for your patch. I tested it and looks ok for me. The commit was made inside the IDE and the issue update too, so the link is not correct. The correct link is http://hg.netbeans.org/main/contrib/rev/870582a9a83c

Regards
Comment 14 Jiri Kovalsky 2010-04-08 14:57:11 UTC
Thanks Michel for your review & integration and special thanks to Eric for the patch!
Comment 15 misterm 2010-04-14 12:52:23 UTC
Could not reproduce anymore, seems fixed.