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 195778

Summary: [70cat] javax.swing.text.BadLocationException: Invalid offset=3689, docLen=3685
Product: editor Reporter: aldobrucale <aldobrucale>
Component: Painting & PrintingAssignee: Miloslav Metelka <mmetelka>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: P3    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter: 176895
Attachments: stacktrace

Description aldobrucale 2011-02-21 17:49:45 UTC
This bug was originally marked as duplicate of bug 186474, that is already resolved. This bug is still valid, so this seems to be another bug, but it might be related.

Build: NetBeans IDE Dev (Build 201102200501)
VM: Java HotSpot(TM) Client VM, 17.1-b03, Java(TM) SE Runtime Environment, 1.6.0_22-b04
OS: Linux

User Comments:
aldobrucale: ctrl-z in xml document (spring file in javase project)

aldobrucale: ctrl-z in xml




Stacktrace: 
javax.swing.text.BadLocationException: Invalid offset=3689, docLen=3685
   at org.netbeans.modules.editor.lib2.view.EditorView.checkBounds(EditorView.java:539)
   at org.netbeans.modules.editor.lib2.view.EditorView.modelToView(EditorView.java:250)
   at javax.swing.plaf.basic.BasicTextUI$RootView.modelToView(BasicTextUI.java:1497)
   at javax.swing.plaf.basic.BasicTextUI.modelToView(BasicTextUI.java:1035)
   at javax.swing.plaf.basic.BasicTextUI.modelToView(BasicTextUI.java:1010)
   at javax.swing.text.JTextComponent.modelToView(JTextComponent.java:1400)
Comment 1 aldobrucale 2011-02-21 17:49:50 UTC
Created attachment 106264 [details]
stacktrace
Comment 2 Miloslav Metelka 2011-02-23 14:52:49 UTC
Unfortunately this indicates that views update in insertUpdate/removeUpdate did not update last view's end offset properly and so

  Rectangle rec2 = component.modelToView(view.getEndOffset() - 1);

picks a wrong offset.
Is this a reproducible problem or random?
Comment 3 aldobrucale 2011-02-23 15:59:17 UTC
It happens randomly, but it does happen once in a while. I was undoing a long list of changes, keeping ctrl-z pressed: may be a threading problem? Is there any runtime flag I may set to facilitate debugging if it happens again?
Comment 4 Miloslav Metelka 2011-03-10 14:14:05 UTC
Yes, it was a race condition. I believe that the changes in issue 195432 should eliminate this problem as well so I mark it as duplicate.
If the problem would persist even in 7.0 RC1 please reopen the issue. Thanks.

*** This bug has been marked as a duplicate of bug 195432 ***