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 16696 - Exception first time editor is shown/file is loaded
Summary: Exception first time editor is shown/file is loaded
Status: CLOSED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Text (show other bugs)
Version: 3.x
Hardware: Sun Solaris
: P2 blocker (vote)
Assignee: Peter Zavadsky
URL:
Keywords:
Depends on: 17144
Blocks:
  Show dependency tree
 
Reported: 2001-10-18 17:29 UTC by Torbjorn Norbye
Modified: 2008-12-22 18:54 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Torbjorn Norbye 2001-10-18 17:29:53 UTC
I've seen this bug for several months, off and on. It appears to be a race
condition, because it does not occur reproducibly. 

Every now and then when I start the debugger and the editor is started
(to show the current location), I get the below exception thrown. This produces
a popup dialog with an exception which is unnerving to the user.   It doesn't
seem to "cause anything bad" to happen however.  I used to think perhaps this
was due to a bug in my own editor kit (since I typically load up C++ source
files),
but right now it happened when I loaded in a Java file.

I've mentioned this bug and provided a stacktrace to David (Konecny) before,
and he suggested I file a bug if it occurs again with fresh sources.  And
today's
occurrence happened with a brand new build from sources.

java.lang.IllegalArgumentException: Line index=-1 must be >= 0
        at

org.netbeans.editor.BaseDocument$LineRootElement.getElement(BaseDocument.java:1127)
        at org.openide.text.NbDocument.findLineOffset(NbDocument.java:116)
        at
 org.openide.text.PositionRef$Manager$LineKind.toMemory(PositionRef.java:516)
        at
org.openide.text.PositionRef$Manager.documentOpened(PositionRef.java:242)
        at

org.openide.text.CloneableEditorSupport$Listener.run(CloneableEditorSupport.java:1387)
        at org.openide.util.Task.run(Task.java:152)
        at
 org.openide.text.CloneableEditorSupport$1.run(CloneableEditorSupport.java:302)
        at org.openide.util.Task.run(Task.java:152)
        at java.lang.Thread.run(Thread.java:484)
Thu Oct 18 09:21:22 PDT 2001: java.lang.IllegalArgumentException: Line index=-1
must
 be >= 0
java.lang.IllegalArgumentException: Line index=-1 must be >= 0
        at

org.netbeans.editor.BaseDocument$LineRootElement.getElement(BaseDocument.java:1127)
        at org.openide.text.NbDocument.findLineOffset(NbDocument.java:116)
        at
 org.openide.text.PositionRef$Manager$LineKind.toMemory(PositionRef.java:516)
        at
org.openide.text.PositionRef$Manager.documentOpened(PositionRef.java:242)
        at

org.openide.text.CloneableEditorSupport$Listener.run(CloneableEditorSupport.java:1387)
        at org.openide.util.Task.run(Task.java:152)
        at
 org.openide.text.CloneableEditorSupport$1.run(CloneableEditorSupport.java:302)
        at org.openide.util.Task.run(Task.java:152)
[catch] at java.lang.Thread.run(Thread.java:484)
Comment 1 Miloslav Metelka 2001-10-19 12:35:49 UTC
Hi Tor, I think that we need some further steps to reproduce it e.g.
if you set some breakpoint etc.
The problem is that there are some "bad" positionrefs created for the
document. Once the editor gets opened their original positions cannot
be restored. The editor is not involved very much in this problem
because although the editor throws the exception it cannot do anything
reasonable because it gets asked to return the line-element for the
line with index -1. There must be some code in PositionRef in the
openide that will decide what should be done once the position cannot
be restored. Reassigning to openide. 
Comment 2 Jan Zajicek 2001-10-19 13:27:34 UTC
Assigning.
Comment 3 Peter Zavadsky 2001-10-19 16:18:53 UTC
Fixed in [main-trunk].

I looked at the code and there seems to be only way to get PostionRef
to invalid state.
And that is if there is a StyledDocument which Position getOffset()
returns -1, which is wrong. (Then this value is internally used as
flag which then confuses PositionRef later).

 Now this condition should be handled. When serializing such invalid
PositionRef it will thrown IOException which describes the problematic
Position, StyledDocument and also CloneableEditorSupport instances.
 Thus such invalid PostionRef won't be serialized and when
deserializing not incorrectly recognized as another kind (the flag) of
PositionRef. So you shouldn't get your exception anymore.

But you should get the IOException decsribing the problematic
StyledDocument&Position. Then file an issue against their implementors.

Fix:
openide/../openide/text/PositionRef.java [1.38]
                       /Bundle.properties [1.32]
Comment 4 Jan Zajicek 2001-10-23 14:21:37 UTC
#20011023
Comment 5 Marian Mirilovic 2002-01-30 15:14:50 UTC
- only for sustaining team

[Jumbo_Patch 3.2]

IndexOutOfBoundsException arise again on FFJ3.0  with JP3.2. 

IMHO :
This issue cause impossibility to save file which you were open ->
data lost!

By the way , this one is the same as issue 13385.
Comment 6 Quality Engineering 2003-07-01 16:28:43 UTC
Resolved for 3.4.x or earlier, no new info since then -> closing.