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 43954 - javax.swing.text.BadLocationException: reqPos=2634, reqLen=-2379, doc.getLength()=2643
Summary: javax.swing.text.BadLocationException: reqPos=2634, reqLen=-2379, doc.getLeng...
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Code folding (show other bugs)
Version: 3.x
Hardware: PC Windows XP
: P3 blocker (vote)
Assignee: issues@editor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-28 00:04 UTC by _ potingwu
Modified: 2007-11-05 13:39 UTC (History)
0 users

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 _ potingwu 2004-05-28 00:04:49 UTC
Often got the following exception:

javax.swing.text.BadLocationException:
reqPos=2634, reqLen=-2379, doc.getLength()=2643
       at
org.netbeans.editor.LineRootElement.prepareSyntax(LineRootElement.java:203)
       at
org.netbeans.editor.BaseDocument.prepareSyntax(BaseDocument.java:1251)
       at
org.netbeans.editor.SyntaxSupport.tokenizeText(SyntaxSupport.java:363)
       at
org.netbeans.modules.editor.java.NbJavaFoldMaintainer.updateFoldsForClass(NbJavaFoldMaintainer.java:391)
       at
org.netbeans.modules.editor.java.NbJavaFoldMaintainer.updateFolds(NbJavaFoldMaintainer.java:623)
       at
org.netbeans.modules.editor.java.NbJavaFoldMaintainer.initFolds(NbJavaFoldMaintainer.java:153)
       at
org.netbeans.editor.fold.spi.FoldHierarchySpi.rebuildMaintainers(FoldHierarchySpi.java:673)
       at
org.netbeans.editor.fold.spi.FoldHierarchySpi.rebuild(FoldHierarchySpi.java:606)
       at
org.netbeans.editor.fold.spi.FoldHierarchySpi$1.propertyChange(FoldHierarchySpi.java:719)
       ...


In NbJavaFoldMaintainer.java,
Ln#383:            int startOffset =
elem.getStartOffset();
Ln#384:            int endOffset =
elem.getEndOffset();

startOffset = reqPos = 2634
endOffset = 255

that caused reqLen = -2379.

I guess "2634" is for the full doc, and "255" is
for the collapsed doc. Is it some kind of sync.
problem (race condition)

And sometimes we also got the following
exceptions, maybe from the same reason:

java.lang.IndexOutOfBoundsException: Invalid line
index=92 >= lineCount=92
       at
org.netbeans.editor.LineRootElement.getElement(LineRootElement.java:54)
       at
org.openide.text.NbDocument$DocumentRenderer.run(NbDocument.java:631)
       at
org.netbeans.editor.BaseDocument.render(BaseDocument.java:883)
       at
org.openide.text.NbDocument$DocumentRenderer.renderToInt(NbDocument.java:609)
       at
org.openide.text.NbDocument.findLineOffset(NbDocument.java:142)
       at
org.openide.text.DocumentLine$Set.getCurrent(DocumentLine.java:904)
       ...

Po-Ting
Comment 1 Miloslav Metelka 2004-06-08 16:35:22 UTC
The first part of the problem should be fixed by the fix of issue
42504 (already backported into custom_folds).
Could you please provide a full stacktrace of the second problem? I
would like to know from where the
org.openide.text.DocumentLine$Set.getCurrent(DocumentLine.java:904)
gets called because the DocumentLine.Set.getCurrent() is declared to
throw the exception in case the given line is invalid so the caller
should be aware of that. Thanks.
Comment 2 Miloslav Metelka 2004-08-10 14:00:49 UTC
No info provided thus closing. Please reopen if the problem persists.