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 14803 - NPE from Annotations.removeAnnotation
Summary: NPE from Annotations.removeAnnotation
Status: CLOSED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 3.x
Hardware: PC Linux
: P3 blocker (vote)
Assignee: issues@editor
URL:
Keywords:
: 15393 15442 15693 16385 28556 31483 33333 35400 36211 37062 39324 43044 44041 (view as bug list)
Depends on:
Blocks:
 
Reported: 2001-08-25 16:20 UTC by Jesse Glick
Modified: 2007-11-05 13:44 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Stack trace (2.04 KB, text/plain)
2001-08-25 16:20 UTC, Jesse Glick
Details
NPE from AnnotationTypesFolder.saveAnnotationType right after reloading Ant layer (2.62 KB, text/plain)
2001-09-20 11:39 UTC, Jesse Glick
Details
NPE (4.81 KB, text/plain)
2001-09-26 18:05 UTC, Lukas Hasik
Details
NullPointerException (2.58 KB, text/plain)
2001-09-27 20:21 UTC, Jesse Glick
Details
Editor part of the fix of this issue (15.62 KB, patch)
2003-09-05 15:23 UTC, Miloslav Metelka
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2001-08-25 16:20:16 UTC
[dev aug 22] When closing some Output Window tab that had linked to a
document with error annotations, got an NPE.
Comment 1 Jesse Glick 2001-08-25 16:20:57 UTC
Created attachment 2301 [details]
Stack trace
Comment 2 David Konecny 2001-08-27 13:53:28 UTC
Is the problem always reproducible? I simulated some errors and 
executed ant task. I was able to see your new "Ant Build Errors" 
annotations, but closing Output Window with a few linked annotations 
did not raise any exception.

(I would like to find the cause of the problem. In worst case I can 
always add into code from stack trace some "if"s. But this situation 
should not happen, so the problem must be somewhere else!)
Comment 3 Jesse Glick 2001-08-28 19:49:43 UTC
No, I don't think it is reproducible, sorry.
Comment 4 David Konecny 2001-09-17 13:02:56 UTC
*** Issue 15442 has been marked as a duplicate of this issue. ***
Comment 5 David Konecny 2001-09-17 13:07:04 UTC
*** Issue 15393 has been marked as a duplicate of this issue. ***
Comment 6 Jesse Glick 2001-09-20 11:38:01 UTC
I thought I had also reported an NPE in saveAnnotationType, but now I
cannot find this in IssueZilla. Anyway this happened to me in [dev sep
17].
Comment 7 Jesse Glick 2001-09-20 11:39:50 UTC
Created attachment 2618 [details]
NPE from AnnotationTypesFolder.saveAnnotationType right after reloading Ant layer
Comment 8 David Konecny 2001-09-20 12:32:38 UTC
Thanx for report Jesse. At first glance it seems to me as some other 
problem, but I'm going to double check it and if necessary I will 
create separate issue. 

I was able to reproduce the NPE in removeAnnotation and will commit 
fix today.
Comment 9 David Konecny 2001-09-20 13:03:41 UTC
The problem (NPE from Annotations.removeAnnotation) was fixed in these 
files:

Checking in src/org/openide/text/Annotation.java;
new revision: 1.6; previous revision: 1.5
Checking in src/org/openide/text/CloneableEditorSupport.java;
new revision: 1.42; previous revision: 1.41
Checking in src/org/openide/text/DocumentLine.java;
new revision: 1.34; previous revision: 1.33
Checking in src/org/openide/text/EnhancedChangeEvent.java;
initial revision: 1.1
Checking in src/org/openide/text/PositionRef.java;
new revision: 1.37; previous revision: 1.36

I'm leaving the issue opened, because of additional exception attached 
 which I must investigate first.
Comment 10 Jan Lahoda 2001-09-20 13:11:24 UTC
I have created Issue #15692 for latter exception. Close it as
duplicate if the cause is the same.
Now, I am closing this bug as fixed. Reopen if you disagree.
Comment 11 David Konecny 2001-09-20 13:14:54 UTC
Honza! you was just a bit faster than me! I appologize for the chaos, 
here is the eplanation:

I'm silly - I did not read Jesse's comment carefully. It is definitely 
the issue 14804 - the folder with annotation types still doesn't 
listen on changes. I would like to fix the 14804 problem ASAP!
Comment 12 David Konecny 2001-09-20 14:35:06 UTC
*** Issue 15693 has been marked as a duplicate of this issue. ***
Comment 13 Lukas Hasik 2001-09-26 18:04:38 UTC
build 200109260100

I received attached exception. I'm not able to reproduce it again. I
followed steps : compile java with errors, click on error in output
window (issue 15693).
Please recheck your fix.
Comment 14 Lukas Hasik 2001-09-26 18:05:43 UTC
Created attachment 2715 [details]
NPE
Comment 15 David Konecny 2001-09-27 08:38:27 UTC
I have some idea where the remaining problem might be and going to 
check it.
Comment 16 Jesse Glick 2001-09-27 20:21:00 UTC
I also saw an NPE from NbEditorDocument.removeAnnotation in [dev sep
26].

Not reproducible, but occurred while clearing Output Window that had
some Ant hyperlinks in it. Usually this just removes all the
annotations. This time it threw an exception. Note that the Ant
annotation first checks for getAnnotatable() and only if non-null does
it call detach().
Comment 17 Jesse Glick 2001-09-27 20:21:36 UTC
Created attachment 2757 [details]
NullPointerException
Comment 18 David Konecny 2001-10-01 10:35:07 UTC
I know the cause and testing the fix right now.
Comment 19 David Konecny 2001-10-02 09:53:02 UTC
Another attempt to fix this bug and I hope the final and successfull. 
If it happens again please reopen and attach stack trace. The whole 
problem was that add/remove were not synchronized correctly.

Checking in src/org/openide/text/Annotation.java;
new revision: 1.7; previous revision: 1.6
Checking in src/org/openide/text/DocumentLine.java;
new revision: 1.37; previous revision: 1.36
Checking in src/org/openide/text/NbDocument.java;
new revision: 1.45; previous revision: 1.44
Comment 20 David Konecny 2001-10-09 15:38:22 UTC
*** Issue 16385 has been marked as a duplicate of this issue. ***
Comment 21 Martin Roskanin 2003-01-27 12:48:37 UTC
*** Issue 28556 has been marked as a duplicate of this issue. ***
Comment 22 Martin Roskanin 2003-01-27 12:53:38 UTC
The issue has been reproduced again.  The problem seems to be in no
synchronization of adding and removing annotations from cache
elements. Namely the Map lineAnnotationsByMark and the List
lineAnnotationsArray.
Comment 23 David Konecny 2003-01-27 15:10:39 UTC
Martin plan to work on this issue.
Comment 24 Miloslav Metelka 2003-02-12 14:29:49 UTC
I have fixed the NPE reported by Jesse in maintrunk:
Checking in src/org/netbeans/modules/editor/NbEditorDocument.java;
/cvs/editor/src/org/netbeans/modules/editor/NbEditorDocument.java,v 
<--  NbEditorDocument.java
new revision: 1.31; previous revision: 1.30
done
Comment 25 Martin Roskanin 2003-02-26 13:30:05 UTC
*** Issue 31483 has been marked as a duplicate of this issue. ***
Comment 26 Martin Roskanin 2003-02-26 13:31:25 UTC
Unfortunatelly I have to reopen the issue again. It seems the
synchronization is inevitable ...
Comment 27 Martin Roskanin 2003-06-16 09:35:07 UTC
*** Issue 33333 has been marked as a duplicate of this issue. ***
Comment 28 Martin Roskanin 2003-07-11 14:34:01 UTC
It seems this issue is also connected with wrong positions handling
after external modification of the document and succeeding reloading.
See issue #25595

Repro:
1. add breakpoint somewhere at the end of document
2. make external modification (delete several lines from the end,
including the line where the breakpoint was)-> document will be reloaded

(during reloading of document all breakpoints are removed from
document and after reloading they are setted back.) Our added
breakpoint is removed and then it should be added to a new offset
(document is different after ext. modification). But the position is
obsolete. ( and anno offset is higher as doc.length) That's why a
BadLocationException occurs in addAnnotation method in Annotations
class. The exception is caught and return statement finishes further
adding annotation operations. It causes that the added annotation is
not inserted into lineAnnotationsByMark Map. After next call of
removeAnnotation a LineAnnotations is going to be retrieved from the
Map. But null value is returned.
Comment 29 Martin Roskanin 2003-08-13 16:56:04 UTC
*** Issue 35400 has been marked as a duplicate of this issue. ***
Comment 30 Miloslav Metelka 2003-09-05 15:22:53 UTC
Attaching potential fix. The fix requires fix of issue 35914 that was
already commited into trunk. The fix also relies on fix of issue 33165
and issue 35930. I'll commit them at once.
Comment 31 Miloslav Metelka 2003-09-05 15:23:58 UTC
Created attachment 11529 [details]
Editor part of the fix of this issue
Comment 32 Martin Roskanin 2003-09-23 14:03:01 UTC
*** Issue 36211 has been marked as a duplicate of this issue. ***
Comment 33 bitwise 2003-09-30 22:17:55 UTC
    I opened a source file with two editors. One was Netbeans source
editor, another was an external editor. I edited and saved the source
file in the external editor and activate the Netbeans source editor.
These steps often make the source editor fail to reload the source file.
    I tried to compile the source file when the source editor failed
to reload it, then that NPE was thrown. I will attach the last part of
my ide.log later. Thanks.
Comment 34 bitwise 2003-09-30 22:35:03 UTC
    I'm sorry that the problem in my previous comments is already
pointed out and this problem have been fixed. I stop to attach the log.
Comment 35 Martin Roskanin 2003-11-13 15:05:38 UTC
*** Issue 37062 has been marked as a duplicate of this issue. ***
Comment 36 Miloslav Metelka 2004-01-20 13:40:10 UTC
This problem should be fixed by the fix of issue 33165. Please reopen
if the symptoms would reappear.
Comment 37 Martin Roskanin 2004-05-04 14:00:34 UTC
*** Issue 39324 has been marked as a duplicate of this issue. ***
Comment 38 Martin Roskanin 2004-05-12 12:45:35 UTC
*** Issue 43044 has been marked as a duplicate of this issue. ***
Comment 39 Lukas Hasik 2004-05-31 13:42:29 UTC
*** Issue 44041 has been marked as a duplicate of this issue. ***
Comment 40 Jiri Prox 2006-04-07 08:49:04 UTC
v