You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by bu...@apache.org on 2002/12/11 19:22:44 UTC
DO NOT REPLY [Bug 15285] New: -
RegexFunction.java: If Nth match not found -> the whole request is quietly cancelled (Patch included)
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15285>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15285
RegexFunction.java: If Nth match not found -> the whole request is quietly cancelled (Patch included)
Summary: RegexFunction.java: If Nth match not found -> the whole
request is quietly cancelled (Patch included)
Product: JMeter
Version: Nightly (Please specify date)
Platform: All
OS/Version: Other
Status: NEW
Severity: Minor
Priority: Other
Component: Main
AssignedTo: jmeter-dev@jakarta.apache.org
ReportedBy: jarno.pelkonen@exidio.com
There is a bug in Jmeter 1.8. The bug exist in CVS version too (11.12.2002
17:55 UTC).
The bug occurs if one uses regexfunction to form a request with the way that
Nth match should be returned ("which match to use" -field). If there is no Nth
match, but only N-1 matches the most, Jmeter quietly cancels the request
without leaving any indication that something went wrong.
the error is in file:
/functions/org/apache/jmeter/functions/RegexFunction.java
and in method "execute". (lines 125->)
The code does not consider such a situation that there are matches but not Nth
match. The "try - catch" catches only "NumberFormatExceptions", not for
IndexOutOfBoundsException". "execute" method should return "defaultValue", but
it does not.
My suggestion is to add a "try - catch" clause around the "else" -branch as
shown below. Compiles and works. I don't have (non-anonymous) CVS access, so I
can't do it myself.
Regards,
Jarno
jarno.pelkonen@exidio.com
------CVS Version 1.6 ------------------
try {
int index = Integer.parseInt(valueIndex) - 1;
MatchResult result = (MatchResult)collectAllMatches.get(index);
return generateResult(result);
} catch(NumberFormatException e) {
float ratio = Float.parseFloat(valueIndex);
MatchResult result = (MatchResult)collectAllMatches.get(
(int)(collectAllMatches.size() * ratio + .5) - 1);
return generateResult(result);
}
---------- FIX --------------------
try {
try {
int index = Integer.parseInt(valueIndex) - 1;
MatchResult result = (MatchResult)collectAllMatches.get(index);
return generateResult(result);
} catch(NumberFormatException e) {
float ratio = Float.parseFloat(valueIndex);
MatchResult result = (MatchResult)collectAllMatches.get((int)
(collectAllMatches.size() * ratio + .5) - 1);
return generateResult(result);
}
} catch (IndexOutOfBoundsException e) {
return defaultValue;
}
--------------------------------
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>