Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-19670

camel-core - Splitter fails with "Caused by: java.io.IOException: Stream closed"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.21.0
    • 3.21.1, 3.22.0, 4.0.0
    • camel-core
    • None
    • Unknown

    Description

      The recent change introduced in scope of CAMEL-18619 causes Splitter to fail when 

      org.apache.camel.model.errorhandler.DefaultErrorHandlerDefinition#setUseOriginalBody

       is set to true. This is because Splitter creates a new Unit of Work and it consumes the stream in 

      org.apache.camel.impl.engine.DefaultUnitOfWork#doOnPrepare

      Subsequently,

      org.apache.camel.impl.engine.CamelInternalProcessor.StreamCachingAdvice#before

      tries to consume this stream when the split subroute is executed and it fails with:

      org.apache.camel.StreamCacheException: Error during type conversion from type: org.apache.camel.dataformat.zipfile.ZipInputStreamWrapper to the required type: org.apache.camel.StreamCache with value org.apache.camel.dataformat.zipfile.ZipInputStreamWrapper@20ac325b due to org.apache.camel.TypeConversionException: Error during type conversion from type: org.apache.camel.dataformat.zipfile.ZipInputStreamWrapper to the required type: org.apache.camel.StreamCache with value org.apache.camel.dataformat.zipfile.ZipInputStreamWrapper@20ac325b due to java.io.IOException: Stream closed
      at org.apache.camel.impl.engine.CamelInternalProcessor$StreamCachingAdvice.before(CamelInternalProcessor.java:960)
      at org.apache.camel.impl.engine.CamelInternalProcessor$StreamCachingAdvice.before(CamelInternalProcessor.java:911)
      at org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:335)
      at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$RedeliveryTask.doRun(RedeliveryErrorHandler.java:829)
      at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$RedeliveryTask.run(RedeliveryErrorHandler.java:737)
      at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:181)
      at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:59)
      at org.apache.camel.processor.Pipeline.process(Pipeline.java:165)
      at org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:392)
      at org.apache.camel.component.seda.SedaConsumer.sendToConsumers(SedaConsumer.java:269)
      at org.apache.camel.component.seda.SedaConsumer.doRun(SedaConsumer.java:187)
      at org.apache.camel.component.seda.SedaConsumer.run(SedaConsumer.java:130)
      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      at java.base/java.lang.Thread.run(Thread.java:829)
      Caused by: org.apache.camel.TypeConversionException: Error during type conversion from type: org.apache.camel.dataformat.zipfile.ZipInputStreamWrapper to the required type: org.apache.camel.StreamCache with value org.apache.camel.dataformat.zipfile.ZipInputStreamWrapper@20ac325b due to java.io.IOException: Stream closed
      at org.apache.camel.converter.stream.StreamCacheBulkConverterLoader.convertTo(StreamCacheBulkConverterLoader.java:60)
      at org.apache.camel.impl.converter.CoreTypeConverterRegistry.doConvertTo(CoreTypeConverterRegistry.java:449)
      at org.apache.camel.impl.converter.CoreTypeConverterRegistry.doConvertTo(CoreTypeConverterRegistry.java:358)
      at org.apache.camel.impl.converter.CoreTypeConverterRegistry.convertTo(CoreTypeConverterRegistry.java:202)
      at org.apache.camel.impl.engine.DefaultStreamCachingStrategy.cache(DefaultStreamCachingStrategy.java:226)
      at org.apache.camel.impl.engine.DefaultStreamCachingStrategy.cache(DefaultStreamCachingStrategy.java:217)
      at org.apache.camel.impl.engine.CamelInternalProcessor$StreamCachingAdvice.before(CamelInternalProcessor.java:953)
      ... 14 common frames omitted
      Caused by: java.io.IOException: Stream closed
      at java.base/java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:176)
      at java.base/java.io.BufferedInputStream.read(BufferedInputStream.java:342)
      at java.base/java.io.FilterInputStream.read(FilterInputStream.java:107)
      at org.apache.camel.util.IOHelper.copy(IOHelper.java:193)
      at org.apache.camel.util.IOHelper.copy(IOHelper.java:161)
      at org.apache.camel.util.IOHelper.copy(IOHelper.java:156)
      at org.apache.camel.util.IOHelper.copyAndCloseInput(IOHelper.java:229)
      at org.apache.camel.util.IOHelper.copyAndCloseInput(IOHelper.java:225)
      at org.apache.camel.converter.stream.StreamCacheConverter.convertToStreamCache(StreamCacheConverter.java:54)
      at org.apache.camel.converter.stream.StreamCacheBulkConverterLoader.doConvertTo(StreamCacheBulkConverterLoader.java:78)
      at org.apache.camel.converter.stream.StreamCacheBulkConverterLoader.convertTo(StreamCacheBulkConverterLoader.java:51)
      ... 20 common frames omitted

      Please find the unit test attached. It works with Camel 3.20.4 and fails with Camel 3.21.0.

      Attachments

        Issue Links

          Activity

            People

              davsclaus Claus Ibsen
              bartoszpop Bartosz Popiela
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: