I found the problem and have a fix.
The problem is cause by parsing of the lead space character when intSum()
parses the input parameters.
bad=${__intSum(${start}, ${counter})}
Notice there is a space character after the , and before $.
The line that failed to parse this properly is IntSum.java line 64.
Here is the fix:
current code with parsing error:
String varName = ((CompoundVariable) values[values.length - 1]).execute();
corrected code which remove any leading and trailing space:
String varName = ((CompoundVariable) values[values.length -
1]).execute().trim();
I've compared my fix to IntSum.java and LongSum.java (which already works).
Looks like whoever fixed LongSum.java forgot to apply the same to IntSum.java.
Implication for other jmeter functions:
Also note that any other jmeter functions that don't properly trim the leading
space will have the same parsing problem. Perhaps a better place to fix this
problem is in CompoundVariable.execute(SampleResult previousResult, Sampler
currentSampler) method. Fixing things in CompoundVariable.execute() means all
jmeter functions will automatically benefit. However, I am not familiar enough
with jmeter source code to have confidence that trimming leading and trailing
spaces in CompoundVariable.execute() won't cause other side effects.
Thanks,
James Liang
-----Original Message-----
From: James Liang [mailto:[email protected]]
Sent: Tuesday, December 10, 2013 4:01 PM
To: [email protected]
Subject: bug: intSum() is broken
Hi all,
I notice intSum() is broken for version 2.10. The function longSum() works
fine.
To reproduce:
create 4 user paramters as follow:
start=5
counter=${__counter(FALSE)}
bad=${__intSum(${start}, ${counter})}
good=${__longSum(${start}, ${counter})}
I've test this inside a loop. Remember __counter() starts with 1.
On 1st pass
bad=5
good=6
On 2nd pass
bad=5
good=7
The jmeter log shows no errors. It'd seem intSum() is always returning the
first parameter without doing the sum operation.
Thanks,
James Liang