Error during type conversion from type: org.apache.camel.converter.stream.FileInputStreamCache to the required type

Solution Verified - Updated -

Issue

  • Bridging http endpoints in camel-undertow throws: "Error during type conversion from type: org.apache.camel.converter.stream.FileInputStreamCache to the required type" when the body size exceeds spool threshold
  • FileInputStreamCache body file written to disk is already deleted before Undertow can send a response to the client
getContext().setStreamCaching(true);
 getContext().getStreamCachingStrategy().setSpoolThreshold(3);
String data = "abcdefg";
 from("undertow:http://localhost:8080/client")
                .setHeader(Exchange.HTTP_METHOD, constant(HttpMethods.POST))
                .to("http4://localhost:8080/server?bridgeEndpoint=true")
                .to("log:lgName?showBody=true")
                .end();
        from("undertow:http://localhost:8080/server?httpMethodRestrict=POST")
                .setBody(simple(data))
                .to("log:lgName?showBody=true")
                .end();

It gives this error

10:52:49.265 [XNIO-1 task-1] ERROR io.undertow.request - UT005071: Undertow request failed HttpServerExchange{ GET /client request {Connection=[keep-alive], ......}}
org.apache.camel.TypeConversionException: Error during type conversion from type: org.apache.camel.converter.stream.FileInputStreamCache to the required type: java.nio.ByteBuffer with value org.apache.camel.converter.stream.FileInputStreamCache@7004a5b4 due Cannot reset stream from file /tmp/camel/camel-tmp-e7ef56b4-ec43-4547-abba-3848a6a68d3d/cos6853789720494692894.tmp
    at org.apache.camel.impl.converter.BaseTypeConverterRegistry.createTypeConversionException(BaseTypeConverterRegistry.java:667)
.................
Caused by: org.apache.camel.RuntimeCamelException: Cannot reset stream from file /tmp/camel/camel-tmp-e7ef56b4-ec43-4547-abba-3848a6a68d3d/cos6853789720494692894.tmp

Environment

  • Red Hat Fuse
    • 7.4

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content