Bug 61054 - Endless loop in JOrphanUtils#replaceAllWithRegex
Summary: Endless loop in JOrphanUtils#replaceAllWithRegex
Status: RESOLVED FIXED
Alias: None
Product: JMeter
Classification: Unclassified
Component: Main (show other bugs)
Version: 3.2
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-29 09:40 UTC by Felix Schumacher
Modified: 2017-04-29 12:21 UTC (History)
0 users



Attachments
Don't replace the matcher (1.49 KB, patch)
2017-04-29 10:06 UTC, Felix Schumacher
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Felix Schumacher 2017-04-29 09:40:03 UTC
When replacing a string with a string, that includes the search, it will lead to an endless loop in JOrphanUtils#replaceAllWithRegex.

A simple testcase can be constructed using a ThreadGroup containing a HTTP Sampler with a Parameter having a key "name" and a value "abc".

Now, if try a find replace with "abc" as the search and "abcabc" as the replacement, "replace all" will never come to a halt :(
Comment 1 Felix Schumacher 2017-04-29 10:06:21 UTC
Created attachment 34963 [details]
Don't replace the matcher

Instead of replacing the matcher and using replaceFirst, take appendReplacement on the one and only matcher.
Comment 2 Felix Schumacher 2017-04-29 12:21:30 UTC
Will be included in version 3.3.

Date: Sat Apr 29 12:18:36 2017
New Revision: 1793191

URL: http://svn.apache.org/viewvc?rev=1793191&view=rev
Log:
Endless loop in JOrphanUtils#replaceAllWithRegex when regex is contained in replacement

Bugzilla Id: 61054

Modified:
    jmeter/trunk/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java
    jmeter/trunk/test/src/org/apache/jorphan/util/TestJorphanUtils.java
    jmeter/trunk/xdocs/changes.xml