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 166461 - IndexOutOfBoundsException: end=5373 > length()=1027
Summary: IndexOutOfBoundsException: end=5373 > length()=1027
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Search (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker with 1 vote (vote)
Assignee: Miloslav Metelka
URL: http://statistics.netbeans.org/except...
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-03 10:20 UTC by lisukorin
Modified: 2011-02-04 09:46 UTC (History)
11 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 150915


Attachments
stacktrace (3.38 KB, text/plain)
2009-06-03 10:21 UTC, lisukorin
Details
stacktrace (3.28 KB, text/plain)
2009-06-15 18:48 UTC, dfa
Details
stacktrace (3.38 KB, text/plain)
2009-06-21 11:06 UTC, meowman
Details
stacktrace (3.38 KB, text/plain)
2009-06-29 20:08 UTC, devon_c_miller
Details
test case (15 bytes, text/plain)
2010-12-02 12:33 UTC, owe
Details

Note You need to log in before you can comment on or make changes to this bug.
Description lisukorin 2009-06-03 10:20:56 UTC
This issue was originally marked as duplicate of issue 164395, that is already resolved. This issue is still valid, so this seems to be another issue, but it might be related.

Build: NetBeans IDE 6.7 RC1 (Build 200905312038)
VM: Java HotSpot(TM) 64-Bit Server VM, 10.0-b23, Java(TM) SE Runtime Environment, 1.6.0_07-b06
OS: Linux, 2.6.24-21-generic, amd64

User Comments:
lisukorin: when I use replace feature (Ctrl+H) and use regular expression
eg.
from: (\d+)
to: @date + $1.minutes



Stacktrace: 
java.lang.IndexOutOfBoundsException: end=5373 > length()=1027
        at org.netbeans.lib.editor.util.CharSequenceUtilities.checkIndexesValid(CharSequenceUtilities.java:532)
        at org.netbeans.lib.editor.util.CharSequenceUtilities.checkIndexesValid(CharSequenceUtilities.java:546)
        at org.netbeans.lib.editor.util.CharSubSequence.checkIndexesValid(CharSubSequence.java:62)
        at org.netbeans.lib.editor.util.CharSubSequence.<init>(CharSubSequence.java:84)
        at org.netbeans.lib.editor.util.AbstractCharSequence.subSequence(AbstractCharSequence.java:95)
        at org.netbeans.modules.editor.lib2.search.DocumentFinder.findReplaceImpl(DocumentFinder.java:289)
Comment 1 lisukorin 2009-06-03 10:21:08 UTC
Created attachment 83128 [details]
stacktrace
Comment 2 Vitezslav Stejskal 2009-06-03 10:46:58 UTC
Reproducible in a dev build. It is necessary to perform the replace operation inside a selected text (eg. select several
lines and then ctrl+H, use regex, make sure Search Selection is ticked, Replace All will crash with the exception).
Comment 3 dfa 2009-06-15 18:48:03 UTC
This issue was originally marked as duplicate of issue 164395, that is already resolved. This issue is still valid, so this seems to be another issue, but it might be related.

Build: NetBeans IDE Dev (Build 200906081401)
VM: Java HotSpot(TM) Client VM, 11.3-b02, Java(TM) SE Runtime Environment, 1.6.0_13-b03
OS: Windows XP, 5.1, x86

User Comments: 
while trying to replace /(.*)/ with /"$1",/  in this selection: 
        file.separator
path.separator
line.separator
java.version



Stacktrace: 
java.lang.IndexOutOfBoundsException: end=453 > length()=57
        at org.netbeans.lib.editor.util.CharSequenceUtilities.checkIndexesValid(CharSequenceUtilities.java:532)
        at org.netbeans.lib.editor.util.CharSequenceUtilities.checkIndexesValid(CharSequenceUtilities.java:546)
        at org.netbeans.lib.editor.util.CharSubSequence.checkIndexesValid(CharSubSequence.java:62)
        at org.netbeans.lib.editor.util.CharSubSequence.<init>(CharSubSequence.java:84)
        at org.netbeans.lib.editor.util.AbstractCharSequence.subSequence(AbstractCharSequence.java:95)
        at org.netbeans.modules.editor.lib2.search.DocumentFinder.findReplaceImpl(DocumentFinder.java:289)
Comment 4 dfa 2009-06-15 18:48:06 UTC
Created attachment 83600 [details]
stacktrace
Comment 5 Exceptions Reporter 2009-06-18 12:45:03 UTC
This issue already has 5 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=150915
Comment 6 meowman 2009-06-21 11:06:32 UTC
Build: NetBeans IDE 6.7 RC3 (Build 200906142201)
VM: Java HotSpot(TM) 64-Bit Server VM, 11.3-b02-83, Java(TM) SE Runtime Environment, 1.6.0_13-b03-211
OS: Mac OS X, 10.5.7, x86_64

User Comments: 
was attempting to do find/replace inside of a block of selected text using regular expressions. Find worked fine, but when clicking on replace it would generate exception ( was trying to replace with some references to regular expression capture group)

Stacktrace: 
java.lang.IndexOutOfBoundsException: end=14241 > length()=1838
        at org.netbeans.lib.editor.util.CharSequenceUtilities.checkIndexesValid(CharSequenceUtilities.java:532)
        at org.netbeans.lib.editor.util.CharSequenceUtilities.checkIndexesValid(CharSequenceUtilities.java:546)
        at org.netbeans.lib.editor.util.CharSubSequence.checkIndexesValid(CharSubSequence.java:62)
        at org.netbeans.lib.editor.util.CharSubSequence.<init>(CharSubSequence.java:84)
        at org.netbeans.lib.editor.util.AbstractCharSequence.subSequence(AbstractCharSequence.java:95)
        at org.netbeans.modules.editor.lib2.search.DocumentFinder.findReplaceImpl(DocumentFinder.java:289)
Comment 7 meowman 2009-06-21 11:06:43 UTC
Created attachment 83848 [details]
stacktrace
Comment 8 Exceptions Reporter 2009-06-21 11:07:00 UTC
This issue already has 6 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=150915
Comment 9 devon_c_miller 2009-06-29 20:08:04 UTC
Build: NetBeans IDE 6.7 RC3 (Build 200906142201)
VM: Java HotSpot(TM) Client VM, 11.0-b15, Java(TM) SE Runtime Environment, 1.6.0_10-rc-b28
OS: Windows XP, 5.1, x86

User Comments: 
Given this input:
  1 - message 1
  2 - message 2
  3 - message 3

1. Open the replace dialog (Ctrl-H)
2. Check "Regular Expressions", "Wrap Around", and "Highlight Results"
3. For "Find What" enter: ^\s*(\d+) - (.*)
4. For "Replace with" enter: new SomeClass(1<<$1, "$2"),
5. With the moouse, select (highlight) the 3 lines of input indicated above
6. Click replace or replace all

This works if you omit step 5.

Stacktrace: 
java.lang.IndexOutOfBoundsException: end=70083 > length()=239
        at org.netbeans.lib.editor.util.CharSequenceUtilities.checkIndexesValid(CharSequenceUtilities.java:532)
        at org.netbeans.lib.editor.util.CharSequenceUtilities.checkIndexesValid(CharSequenceUtilities.java:546)
        at org.netbeans.lib.editor.util.CharSubSequence.checkIndexesValid(CharSubSequence.java:62)
        at org.netbeans.lib.editor.util.CharSubSequence.<init>(CharSubSequence.java:84)
        at org.netbeans.lib.editor.util.AbstractCharSequence.subSequence(AbstractCharSequence.java:95)
        at org.netbeans.modules.editor.lib2.search.DocumentFinder.findReplaceImpl(DocumentFinder.java:289)
Comment 10 devon_c_miller 2009-06-29 20:08:14 UTC
Created attachment 84145 [details]
stacktrace
Comment 11 Exceptions Reporter 2009-06-29 20:08:34 UTC
This issue already has 7 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=150915
Comment 12 Exceptions Reporter 2009-07-01 00:17:20 UTC
This issue already has 8 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=150915
Comment 13 Exceptions Reporter 2009-07-01 00:18:04 UTC
This issue already has 10 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=150915
Comment 14 Exceptions Reporter 2009-07-01 00:18:36 UTC
This issue already has 10 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=150915
Comment 15 Exceptions Reporter 2009-07-04 18:22:13 UTC
This issue already has 11 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=150915
Comment 16 Exceptions Reporter 2009-07-20 10:57:21 UTC
This issue already has 24 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=150915
Comment 17 Miloslav Metelka 2009-07-30 17:18:36 UTC
I'm unable to reproduce the problem with described scenarios in the current dev build. Closing as worksforme - please reopen if the problem persists. 
Comment 18 owe 2010-12-02 12:33:23 UTC
Created attachment 103532 [details]
test case

See comment by owe on how this test case is to be understood.
Comment 19 owe 2010-12-02 12:45:08 UTC
Hi,

it seems indeed that the problem persists. There is a whole list of reports from 2009-08 and after for version 6.7.1 at 

http://statistics.netbeans.org/analytics/exception.do?id=446904


To reproduce, operate on a selection and use regular expressions. Regex on the entire file and ordinary replacement on a selection both do work. 

Example:

File:

a,
b,
c,
.
(See the previously attache file. Note that there is a line above and below the abc content).

Find:
([a-z]),

Replace:
"$1",

Result: The result depends on the selection. While the "Find" button seems to work properly under any cicumstances, the "Replace All" button does not. I did not test the "Replace" button systematically, but it did not respond when the "Replace All" button didn't.

Selection: All (e.g. ctrl+A or mouse)
Result: Works fine

Selection: Line 2-4 (only the abc content, not the lines before and after)
Result:

"$1",
"$1",
c,
.
Ah, if this isn't an instructive misbehaviour. Note that line 4 was selected but did not change!

Selection: Line 3,4
Result: Nothing happens (I bet this is oure IndexOutOfBoundsException).

Have fun!

Olivier
Comment 20 Miloslav Metelka 2011-02-04 09:46:18 UTC
I've tested in a yesterday's dev build there is no exception and the replacement works as expected (the 'c' gets replaced with "c" in the described case etc.) so it was likely fixed by some of previous fixes.
Please reopen if the problem would reappear.