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: r1303688 - /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java
Date Thu, 22 Mar 2012 15:40:18 GMT
On 22 March 2012 13:22, Philippe Mouawad <philippe.mouawad@gmail.com> wrote:
> On Thu, Mar 22, 2012 at 1:07 PM, sebb <sebbaz@gmail.com> wrote:
>
>> On 22 March 2012 12:01, Philippe Mouawad <philippe.mouawad@gmail.com>
>> wrote:
>> > Hello,
>> > with previous code, we might hid initial exception.
>>
>> Don't understand that sentence.
>>
>> If we throw an exception in finally block while an exception is already
> being thrown by write then new exception will hide old one.

OK, understood.

>
>> AFAICT, prior to this change, the close IOE would have been reported.
>>
>> Yes, potentially hiding the initial exception if one occurs in write.
>
>> > Do you really think an exception on close is useful ?
>>
>> For output, generally yes, one needs to know about close failures.
>>
>> Then maybe we should try/catch the block and log but not let it throw on
> close.

Yes, that would be best.

for example, this might work:

IOE saved=null;
...
catch(IOE ioe) {
  saved = ioe;
} finally {
  if (saved != null) {
    JOrphanUtils.closeQuietly(in);
    throw saved;
  } else {
    in.close();
}

The code in the finally block could be converted into a method
closeQuietly(Closeable, IOException) as it should be useful elsewhere.

>
>> For input it's not always essential.
>>
>> > Regards
>> > Philippe
>> >
>> >
>> > On Thu, Mar 22, 2012 at 12:54 PM, sebb <sebbaz@gmail.com> wrote:
>> >
>> >> On 22 March 2012 08:50,  <pmouawad@apache.org> wrote:
>> >> > Author: pmouawad
>> >> > Date: Thu Mar 22 08:50:29 2012
>> >> > New Revision: 1303688
>> >> >
>> >> > URL: http://svn.apache.org/viewvc?rev=1303688&view=rev
>> >> > Log:
>> >> > Made method static and used closeQuietly
>> >> >
>> >> > Modified:
>> >> >
>> >>
>>  jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java
>> >> >
>> >> > Modified:
>> >>
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java
>> >> > URL:
>> >>
>> http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java?rev=1303688&r1=1303687&r2=1303688&view=diff
>> >> >
>> >>
>> ==============================================================================
>> >> > ---
>> >>
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java
>> >> (original)
>> >> > +++
>> >>
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java
>> >> Thu Mar 22 08:50:29 2012
>> >> > @@ -33,6 +33,7 @@ import org.apache.jmeter.protocol.http.u
>> >> >  import org.apache.jmeter.protocol.http.util.HTTPFileArg;
>> >> >  import org.apache.jmeter.samplers.SampleResult;
>> >> >  import org.apache.jmeter.testelement.property.PropertyIterator;
>> >> > +import org.apache.jorphan.util.JOrphanUtils;
>> >> >
>> >> >  /**
>> >> >  * Class for setting the necessary headers for a POST request, and
>> >> sending the
>> >> > @@ -398,7 +399,7 @@ public class PostWriter {
>> >> >      * @param out the stream to write to
>> >> >      * @throws IOException
>> >> >      */
>> >> > -    private void writeFileToStream(String filename, OutputStream
out)
>> >> throws IOException {
>> >> > +    private static void writeFileToStream(String filename,
>> OutputStream
>> >> out) throws IOException {
>> >> >         byte[] buf = new byte[1024];
>> >> >         // 1k - the previous 100k made no sense (there's tons of
>> buffers
>> >> >         // elsewhere in the chain) and it caused OOM when many
>> concurrent
>> >> > @@ -412,7 +413,7 @@ public class PostWriter {
>> >> >             }
>> >> >         }
>> >> >         finally {
>> >> > -            in.close();
>> >> > +            JOrphanUtils.closeQuietly(in);
>> >>
>> >> I'm not sure we want to ignore errors here.
>> >>
>> >> >         }
>> >> >     }
>> >> >
>> >> >
>> >> >
>> >>
>> >
>> >
>> >
>> > --
>> > Cordialement.
>> > Philippe Mouawad.
>>
>
>
>
> --
> Cordialement.
> Philippe Mouawad.

Mime
View raw message