[ 
https://issues.apache.org/jira/browse/CAMEL-19670?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17749143#comment-17749143
 ] 

Bartosz Popiela commented on CAMEL-19670:
-----------------------------------------

Thanks [~davsclaus]! One concern I have is that it will still fail when the 
stream caching is enabled.

> camel-core - Splitter fails with "Caused by: java.io.IOException: Stream 
> closed"
> --------------------------------------------------------------------------------
>
>                 Key: CAMEL-19670
>                 URL: https://issues.apache.org/jira/browse/CAMEL-19670
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 3.21.0
>            Reporter: Bartosz Popiela
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 3.21.1, 3.22.0, 4.0.0
>
>
> The recent change introduced in scope of CAMEL-18619 causes Splitter to fail 
> when 
> {code:java}
> org.apache.camel.model.errorhandler.DefaultErrorHandlerDefinition#setUseOriginalBody{code}
>  is set to true. This is because Splitter creates a new Unit of Work and it 
> consumes the stream in 
> {code:java}
> org.apache.camel.impl.engine.DefaultUnitOfWork#doOnPrepare{code}
> Subsequently,
> {code:java}
> org.apache.camel.impl.engine.CamelInternalProcessor.StreamCachingAdvice#before{code}
> tries to consume this stream when the split subroute is executed and it fails 
> with:
> {noformat}
> 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{noformat}
> Please find the unit [test|https://github.com/bartoszpop/CAMEL-19670] 
> attached. It works with Camel 3.20.4 and fails with Camel 3.21.0.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to