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 225133 - IndexOutOfBoundsException: (offset=531 + length=8)=539 > length()=373
Summary: IndexOutOfBoundsException: (offset=531 + length=8)=539 > length()=373
Status: RESOLVED DUPLICATE of bug 225087
Alias: None
Product: editor
Classification: Unclassified
Component: Painting & Printing (show other bugs)
Version: 7.3
Hardware: All All
: P3 normal (vote)
Assignee: Miloslav Metelka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-21 11:56 UTC by Jan Lahoda
Modified: 2013-01-22 09:16 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter: 197045


Attachments
stacktrace (4.82 KB, text/plain)
2013-01-21 11:56 UTC, Jan Lahoda
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Lahoda 2013-01-21 11:56:17 UTC
Build: NetBeans IDE Dev (Build 20130114-b5a20bd41f6a)
VM: Java HotSpot(TM) 64-Bit Server VM, 23.6-b04, Java(TM) SE Runtime Environment, 1.7.0_11-b21
OS: Linux

User Comments:
jlahoda: Remove trailing whitespaces on all lines, made several enters, save, then undo. Assertions *disabled*.




Stacktrace: 
java.lang.IndexOutOfBoundsException: (offset=531 + length=8)=539 > length()=373
   at org.netbeans.modules.editor.lib2.document.CharContent.removeText(CharContent.java:141)
   at org.netbeans.modules.editor.lib2.document.EditorDocumentContent.removeEdit(EditorDocumentContent.java:172)
   at org.netbeans.modules.editor.lib2.document.ContentEdit$InsertEdit.undo(ContentEdit.java:215)
   at org.netbeans.editor.BaseDocumentEvent.undo(BaseDocumentEvent.java:281)
   at org.netbeans.editor.GuardedDocumentEvent.undo(GuardedDocumentEvent.java:72)
   at org.netbeans.modules.editor.lib2.document.StableCompoundEdit.undo(StableCompoundEdit.java:93)
Comment 1 Jan Lahoda 2013-01-21 11:56:19 UTC
Created attachment 130439 [details]
stacktrace
Comment 2 Jan Lahoda 2013-01-21 12:10:26 UTC
Seems to be caused by the assert on:
openide.text/src/org/openide/text/UndoRedoManager.java:397
- the "add" does not happen when assertions are disabled.

More precise steps to reproduce: enable remove trailing whitespaces on all lines, create a new Java file with main method, create several (~10) new empty lines (with indent) behind the "TODO" comment, save, undo: exception (happened always to me, with -J-da). Does not happen when I removed the assert (kept the addEdit, of course):
diff -r a14f31ffb7ce openide.text/src/org/openide/text/UndoRedoManager.java
--- a/openide.text/src/org/openide/text/UndoRedoManager.java    Sun Jan 20 20:49:50 2013 +0100
+++ b/openide.text/src/org/openide/text/UndoRedoManager.java    Mon Jan 21 13:07:56 2013 +0100
@@ -394,7 +394,7 @@
             if (onSaveTasksEdit == null) {
                 onSaveTasksEdit = new CompoundEdit();
             }
-            assert onSaveTasksEdit.addEdit(edit) : "Cannot add to saveActionsEdit"; // NOI18N
+            onSaveTasksEdit.addEdit(edit);// : "Cannot add to saveActionsEdit"; // NOI18N
             return true;
         }
         WrapUndoEdit wrapEdit = new WrapUndoEdit(this, edit); // Wrap the edit

Might be related to bug #225087 (happened while I was trying to reproduce that) and bug #225052.

We apparently need an "assert with side-effects" warning.
Comment 3 Jan Lahoda 2013-01-22 09:16:39 UTC

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