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 119819

Summary: IAE from DocumentFinder.findReplaceImpl
Product: editor Reporter: Jesse Glick <jglick>
Component: SearchAssignee: Sergey Petrov <sj-nb>
Status: RESOLVED FIXED    
Severity: blocker CC: npotocki
Priority: P3    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: Stack trace

Description Jesse Glick 2007-10-23 17:33:20 UTC
071022. Trying to regexp search and replace:

@@([A-Z_]+)@@

with

${$1}

on e.g.

@@FOO@@

Probably the replacement syntax was wrong, but this was not a very polite way to tell me so.
Comment 1 Jesse Glick 2007-10-23 17:33:45 UTC
Created attachment 51515 [details]
Stack trace
Comment 2 Vitezslav Stejskal 2007-10-24 12:18:11 UTC
Reproducible in a dev build.
Comment 3 Jiri Prox 2008-04-11 00:42:53 UTC
moving opened issues from TM <= 6.1 to TM=Dev
Comment 4 Alexei Mokeev 2009-04-10 10:32:55 UTC
Still the case for 6.7 trunk (20090408):
java.lang.IllegalArgumentException: Illegal group reference
	at java.util.regex.Matcher.appendReplacement(Matcher.java:713)
	at java.util.regex.Matcher.replaceFirst(Matcher.java:861)
	at org.netbeans.modules.editor.lib2.search.DocumentFinder.findReplaceImpl(DocumentFinder.java:253)
	at org.netbeans.modules.editor.lib2.search.DocumentFinder.findReplaceResult(DocumentFinder.java:312)
	at org.netbeans.modules.editor.lib2.search.EditorFindSupport.findReplaceInBlock(EditorFindSupport.java:596)
	at org.netbeans.modules.editor.lib2.search.EditorFindSupport.findReplaceImpl(EditorFindSupport.java:525)
	at org.netbeans.modules.editor.lib2.search.EditorFindSupport.replace(EditorFindSupport.java:693)
Comment 5 Alexei Mokeev 2009-04-16 10:34:51 UTC
*** Issue 160807 has been marked as a duplicate of this issue. ***
Comment 6 Alexei Mokeev 2009-04-16 10:36:36 UTC
A brilliant summary from 160807
--
Ideally the dialog should verify entered regex patterns and clearly communicate errors to the user without crashing.
--
Comment 7 Sergey Petrov 2009-04-20 16:55:42 UTC
suggested fix:
with regedp option on, check entered string on typing and disable replace/find buttons and provide red colored message
at the bottom of replace dialog if pattern is wrong. need to try if it will look good with some empty space if all is ok.
Comment 8 Sergey Petrov 2009-04-22 10:16:52 UTC
http://hg.netbeans.org/jet-main/rev/07c6aa8d366e

finally no additional label was added, red colored search/replace strings are used to show problems.
replace is disabled if pattern is wrong.
Comment 9 Quality Engineering 2009-04-23 08:55:48 UTC
Integrated into 'main-golden', will be available in build *200904230201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/07c6aa8d366e
User: sergeyp@netbeans.org
Log: fix #119819 added online verification for search string and replace string, find replace buttons are disabled in case of error, corresponding text field is highlighted with red.