The method is currently only called by ResponseAssertion, which was
previously doing:
result.setFailureMessage(
new String((byte[]) response.getResponseData()));
[This caused an NPE if the responseData was null.]
At present no extra strings are generated, but I take your point that the
method might prove too popular ...
==
I looked at changing getResponseData() to return an empty byte array instead
of null, but quite a bit of code seemed to rely on checking for null.
I also thought about adding a getResponseDataNotNull() method (but with a
better name!).
I'll probably revert to the empty byte array method - OK?
I'll even make the array static final, just for you ... :-)
S.
-----Original Message-----
From: Jordi Salvat i Alabart [mailto:[EMAIL PROTECTED]
Sent: 02 October 2003 18:33
To: JMeter Developers List
Subject: Re: cvs commit:
jakarta-jmeter/src/core/org/apache/jmeter/samplers SampleResult.java
Hi Sebb.
Such a method generally looks dangerous, since a new String will be
allocated every time it's called, possibly creating a ton of Garbage (or
consuming a ton of memory) if there's a lot of responses processed this
way or they are very large.
Would you mind adding a note to this effect to the method's JavaDoc?
--
Salut,
Jordi.
[EMAIL PROTECTED] wrote:
> sebb 2003/10/02 09:18:22
>
> Modified: src/core/org/apache/jmeter/samplers SampleResult.java
> Log:
> Add convenience method responseDataToString
>
> Revision Changes Path
> 1.10 +13 -2
jakarta-jmeter/src/core/org/apache/jmeter/samplers/SampleResult.java
>
> Index: SampleResult.java
> ===================================================================
> RCS file:
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/samplers/SampleResult.ja
va,v
> retrieving revision 1.9
> retrieving revision 1.10
> diff -u -r1.9 -r1.10
> --- SampleResult.java 7 Sep 2003 18:54:53 -0000 1.9
> +++ SampleResult.java 2 Oct 2003 16:18:21 -0000 1.10
> @@ -255,6 +255,17 @@
> return responseData;
> }
>
> + /**
> + * Convenience method to return responseData as a String
> + *
> + * @return the responseData as a string. If responseData is null
> + * then the empty string is returned, rather than null.
> + */
> + public String responseDatatoString()
> + {
> + return (responseData == null) ? "" : new
String(responseData);
> + }
> +
> public void setSamplerData(String s)
> {
> samplerData = s;
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]