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.

Reply via email to