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 185313 - [69cat] javax.swing.text.BadLocationException: Invalid offset=773 not within <0, 772>
Summary: [69cat] javax.swing.text.BadLocationException: Invalid offset=773 not within ...
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Code folding (show other bugs)
Version: 6.x
Hardware: All All
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
: 154991 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-04-30 13:38 UTC by big_al
Modified: 2011-10-10 12:26 UTC (History)
8 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 168926


Attachments
stacktrace (4.54 KB, text/plain)
2010-04-30 13:39 UTC, big_al
Details

Note You need to log in before you can comment on or make changes to this bug.
Description big_al 2010-04-30 13:38:59 UTC
This bug was originally marked as duplicate of bug 172978, that is already resolved. This bug is still valid, so this seems to be another bug, but it might be related.

Build: NetBeans IDE 6.9 Beta (Build 201004200117)
VM: Java HotSpot(TM) 64-Bit Server VM, 14.3-b01-101, Java(TM) SE Runtime Environment, 1.6.0_17-b04-248-10M3025
OS: Mac OS X

User Comments:
big_al: Invoking autocomplete while implementing a BundleActivator/ServiceListener (OSGi)

GUEST: I did nothing




Stacktrace: 
javax.swing.text.BadLocationException: Invalid offset=773 not within <0, 772>
   at org.netbeans.editor.Utilities.checkOffsetValid(Utilities.java:1415)
   at org.netbeans.editor.Utilities.checkOffsetValid(Utilities.java:1410)
   at org.netbeans.editor.Utilities.getRowStart(Utilities.java:178)
   at org.netbeans.editor.Utilities.getRowStart(Utilities.java:161)
   at org.netbeans.editor.CodeFoldingSideBar.traverseForward(CodeFoldingSideBar.java:332)
   at org.netbeans.editor.CodeFoldingSideBar.getPaintInfo(CodeFoldingSideBar.java:299)
Comment 1 big_al 2010-04-30 13:39:05 UTC
Created attachment 98329 [details]
stacktrace
Comment 2 David Strupl 2010-09-21 11:19:35 UTC
Code fold reaching out of the document. Passing to code folding category ...
Comment 3 Svata Dedic 2011-10-04 06:11:11 UTC
Strange - there seem to be inconsistencies between view model and the document content itself. For example, exception http://statistics.netbeans.org/analytics/exception.do?id=526107 is caused by baseTextUI.getPosFromY(clip.y) returning -1. That may mean incomplete view hierarchy, though. This situation *could* be possibly handled by code folding, e.g. by scheduling a repaint a little later when the view hierarchy settles.

Other class of exceptions, http://statistics.netbeans.org/analytics/exception.do?id=506853 show an inconsistency between Document and its Position:
   Utilities.getRowStart(doc, f.getStartOffset()),
where f.getStartOffset() delegates to j.s.t.Position for the offset value.

I was under impression that Position update synchronously to document content updates and the whole getPaintInfo() executes under read-lock of the Document, so no changes should be allowed during the computation.
Comment 4 Svata Dedic 2011-10-04 07:24:58 UTC
*** Bug 154991 has been marked as a duplicate of this bug. ***
Comment 5 Svata Dedic 2011-10-04 10:05:50 UTC
OK, most cases are covered by jet-main #9502a92fe28f, which fixed offset checking. Cases with offset = -1 remain; the rest of reported exceptions seem unrelated to code folding.
Comment 6 Svata Dedic 2011-10-04 10:36:47 UTC
Changeset: d29ee36105fc
Author:    Svata Dedic <sdedic@netbeans.org>
Date:      2011-10-04 12:36
Message:   When start/end offsets is -1, do not paint any folds. The editor will change size eventually and the sidebar repaints again
Issue #185313 - [69cat] javax.swing.text.BadLocationException: Invalid offset=773 not within <0, 772>
Comment 7 Svata Dedic 2011-10-04 10:37:36 UTC
Note - the other exceptions (hyperlink, ...) seem to originate from the already fixed position check.
Comment 8 Quality Engineering 2011-10-10 12:26:36 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/d29ee36105fc
User: Svata Dedic <sdedic@netbeans.org>
Log: When start/end offsets is -1, do not paint any folds. The editor will change size eventually and the sidebar repaints again
Issue #185313 - [69cat] javax.swing.text.BadLocationException: Invalid offset=773 not within <0, 772>