jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r1382577 - /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AjpSampler.java
Date Mon, 10 Sep 2012 23:16:53 GMT
On 9 September 2012 21:44,  <pmouawad@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$
>
>

Mime
View raw message