camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Käufl <>
Subject Stream closed exception when using camel as http proxy with tomcat servlet
Date Fri, 04 Aug 2017 16:31:27 GMT

following the example provided in,
we are using a route definition as follows to proxy an http endpoint via
a servlet running in Tomcat 8.5.16:



Whenever the http endpoint responds with a status code 304 or - more
specifically - with one of the status codes listed in
a " Stream closed" is logged and the servlet replies
with HTTP Status 500 – Internal Server Error.

I've assembled a (rather) minimal working example to reproduce the

We're experiencing the issue with both the latest camel release 2.19.2
as well as the current master branch.

We can workaround the issue by
 (a) either disabling stream caching for the servlet component
explicitly, by writing:
 (b) or by converting the request(!) body to String in the route:

As far as I understand (and my understanding of camel is still very
limited), there are two problems with this:

1) Shouldn't stream caching be disabled by default? At least that's what
I understood from

The method
oddly calls the method readResponseBodyFromInputStream() which does NOT
seem to take the global stream caching setting into account...

2) The actual issue seems to be a null response body in the HttpMessage
contained in the exchange after

Due to the response body being set to null, it is later tried to re-read
the request (!) body in
org.apache.camel.http.common.DefaultHttpBinding#doWriteResponse, line 391.

If someone can confirm that this is indeed a bug, I'd be happy to open
an issue. It is yet a little unclear to me, however, where the root of
the problem actually lies.

Also I couldn't figure out how to write a camel integration test that
makes use of the servlet component. I'd really appreciate if someone
could point me at an example.

Also note that we couldn't reproduce the behaviour with jetty as a
servlet container.

Kind regards and thanks for your help,

Paul Käufl * * +49-1520-7182305
TNG Technology Consulting GmbH, Betastr. 13a, 85774 Unterföhring
Geschäftsführer: Henrik Klagges, Dr. Robert Dahlke, Gerhard Müller
Sitz: Unterföhring * Amtsgericht München * HRB 135082

View raw message