camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: [HTTP4] HttpProducer close temporary file in CachedOutputStream
Date Tue, 07 Aug 2012 00:21:24 GMT
It sounds good, I just create a JIRA[1] to trace this issue.
[1]https://issues.apache.org/jira/browse/CAMEL-5487

Willem

On Tue, Aug 7, 2012 at 3:25 AM, alexey-s <alexins@mail.ru> wrote:
> I found a nasty bug.
> HttpProducer uses a temporary file within the object CachedOutputStream. If
> the static method doExtractResponseBodyAsStream get an error reading an
> incoming message, we lose information on the temporary file.
> I propose to add a block catch (IOException e) to trap the error and delete
> the temporary file within the mining method CachedOutputStream.close().
>
>
>     private static InputStream doExtractResponseBodyAsStream(InputStream is,
> Exchange exchange) throws IOException {
>         // As httpclient is using a AutoCloseInputStream, it will be closed
> when the connection is closed
>         // we need to cache the stream for it.
>         CachedOutputStream cos = null;
>         try {
>             // This CachedOutputStream will not be closed when the exchange
> is onCompletion
>             cos = new CachedOutputStream(exchange, false);
>             IOHelper.copy(is, cos);
>             // When the InputStream is closed, the CachedOutputStream will
> be closed
>             return cos.getWrappedInputStream();
>         } catch(IOException e) {
>              if(cos != null) {
>                 try { cos.close(); } cact(IOException ignore) {}
>              }
>         }
>         } finally {
>             IOHelper.close(is, "Extracting response body", LOG);
>         }
>     }
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/HTTP4-HttpProducer-close-temporary-file-in-CachedOutputStream-tp5716885.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message