You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by sebb <se...@gmail.com> on 2012/09/11 01:16:53 UTC
Re: svn commit: r1382577 - /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AjpSampler.java
On 9 September 2012 21:44, <pm...@apache.org> wrote:
> Author: pmouawad
> Date: Sun Sep 9 20:44:29 2012
> New Revision: 1382577
>
> URL: http://svn.apache.org/viewvc?rev=1382577&view=rev
> Log:
> Use BufferedOutputStream
> Close body on thread end
>
> Modified:
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AjpSampler.java
>
> Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AjpSampler.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AjpSampler.java?rev=1382577&r1=1382576&r2=1382577&view=diff
> ==============================================================================
> --- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AjpSampler.java (original)
> +++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AjpSampler.java Sun Sep 9 20:44:29 2012
> @@ -16,6 +16,7 @@
> */
> package org.apache.jmeter.protocol.http.sampler;
>
> +import java.io.BufferedInputStream;
> import java.io.ByteArrayInputStream;
> import java.io.ByteArrayOutputStream;
> import java.io.File;
> @@ -39,6 +40,7 @@ import org.apache.jmeter.testelement.pro
> import org.apache.jmeter.testelement.property.PropertyIterator;
> import org.apache.jmeter.util.JMeterUtils;
> import org.apache.jorphan.logging.LoggingManager;
> +import org.apache.jorphan.util.JOrphanUtils;
> import org.apache.log.Logger;
>
> /**
> @@ -131,12 +133,15 @@ public class AjpSampler extends HTTPSamp
> public void threadFinished() {
> if(channel != null) {
> try {
> - channel.close();
> + channel.close();
> } catch(IOException iex) {
> log.debug("Error closing channel",iex);
> }
> }
> channel = null;
> + if(body != null) {
> + JOrphanUtils.closeQuietly(body);
> + }
Not necessary to check for null as closeQuietly does.
> body = null;
> stringBody = null;
> }
> @@ -260,7 +265,7 @@ public class AjpSampler extends HTTPSamp
> String fn = fa.getName();
> File input = new File(fn);
> cl = (int)input.length();
> - body = new FileInputStream(input);
> + body = new BufferedInputStream(new FileInputStream(input));
> setString(HTTPConstants.HEADER_CONTENT_DISPOSITION);
> setString("form-data; name=\""+encode(fa.getParamName())+
> "\"; filename=\"" + encode(fn) +"\""); //$NON-NLS-1$ //$NON-NLS-2$
>
>