jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Milamber <milam...@apache.org>
Subject Re: intSum() is broken; code fix available
Date Thu, 12 Dec 2013 09:21:51 GMT
Hello,

Thanks for your report and your analysis.
I chose to apply the trim() method only in IntSum class like LongSum 
class to avoid incompatibly / side effect with the others functions.

Fix track:
https://issues.apache.org/bugzilla/show_bug.cgi?id=55871

Milamber

Le 12/12/2013 01:06, James Liang a ecrit :
> 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:jliang@andera.com]
> Sent: Tuesday, December 10, 2013 4:01 PM
> To: dev@jmeter.apache.org
> 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
>
>
>


Mime
View raw message