Uploaded image for project: 'Red Hat Fuse'
  1. Red Hat Fuse
  2. ENTESB-11331

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 exceeds spool threshold

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • fuse-7.5-ER1
    • fuse-7.3.1
    • Camel
    • None
    • % %
    • Hide
      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 will give 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], Accept=[text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8], Accept-Language=[en-US,en;q=0.9], Cache-Control=[max-age=0], Accept-Encoding=[gzip, deflate, br], User-Agent=[Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36], Upgrade-Insecure-Requests=[1], Host=[localhost:8080]} response {Accept=[text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8], Accept-Language=[en-US,en;q=0.9], Accept-Encoding=[gzip, deflate, br], breadcrumbId=[ID-adongre-pnq-csb-1567401762272-0-1], User-Agent=[Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36], Upgrade-Insecure-Requests=[1]}}
      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)
      	at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:158)
      	at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:129)
      	at org.apache.camel.component.undertow.UndertowConsumer.handleRequest(UndertowConsumer.java:162)
      	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:360)
      	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: org.apache.camel.RuntimeCamelException: Cannot reset stream from file /tmp/camel/camel-tmp-e7ef56b4-ec43-4547-abba-3848a6a68d3d/cos6853789720494692894.tmp
      	at org.apache.camel.converter.stream.FileInputStreamCache.reset(FileInputStreamCache.java:88)
      	at org.apache.camel.converter.IOConverterOptimised.convertTo(IOConverterOptimised.java:50)
      	at org.apache.camel.impl.converter.OptimisedTypeConverter.convertTo(OptimisedTypeConverter.java:63)
      	at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:300)
      	at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:141)
      
      Show
      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 will give 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], Accept=[text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,* /*;q=0.8], Accept-Language=[en-US,en;q=0.9], Cache-Control=[max-age=0], Accept-Encoding=[gzip, deflate, br], User-Agent=[Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36], Upgrade-Insecure-Requests=[1], Host=[localhost:8080]} response {Accept=[text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/ *;q=0.8], Accept-Language=[en-US,en;q=0.9], Accept-Encoding=[gzip, deflate, br], breadcrumbId=[ID-adongre-pnq-csb-1567401762272-0-1], User-Agent=[Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36], Upgrade-Insecure-Requests=[1]}} 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) at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:158) at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:129) at org.apache.camel.component.undertow.UndertowConsumer.handleRequest(UndertowConsumer.java:162) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:360) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang. Thread .run( Thread .java:748) Caused by: org.apache.camel.RuntimeCamelException: Cannot reset stream from file /tmp/camel/camel-tmp-e7ef56b4-ec43-4547-abba-3848a6a68d3d/cos6853789720494692894.tmp at org.apache.camel.converter.stream.FileInputStreamCache.reset(FileInputStreamCache.java:88) at org.apache.camel.converter.IOConverterOptimised.convertTo(IOConverterOptimised.java:50) at org.apache.camel.impl.converter.OptimisedTypeConverter.convertTo(OptimisedTypeConverter.java:63) at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:300) at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:141)
    • Fuse 7.5 Sprint 51 - Dev #2

    Description

      When stream caching in enabled and multiple http-endponits are called within an undertow consumer route, camel throws this error right before returning the response body to the client:

      08:43:16.567 [XNIO-1 task-2] ERROR io.undertow.request - UT005071: Undertow request failed HttpServerExchange{ GET /testfileinputstreamcache/svcundertest request {Connection=[Keep-Alive], Accept-Encoding=[gzip,deflate], breadcrumbId=[ID-NBS12-1566168193692-0-1], User-Agent=[Apache-HttpClient/4.5.6 (Java/1.8.0_152)], Host=[0.0.0.0:8185]} response {Accept-Encoding=[gzip,deflate], breadcrumbId=[ID-NBS12-1566168193692-0-1], User-Agent=[Apache-HttpClient/4.5.6 (Java/1.8.0_152)]}}
      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@5de19160 due Cannot reset stream from file 
      

      Note: It works fine for camel-jetty9

      Attachments

        Activity

          People

            yfang@redhat.com Freeman(Yue) Fang
            rhn-support-adongre Avinash Dongre
            Jan Bouska Jan Bouska
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: