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

Claus Ibsen commented on CAMEL-24189:
-------------------------------------

Root cause: the test reads the InputStream *after* 
{{mock.assertIsSatisfied()}}, but by that point {{GenericFileOnCompletion}} has 
already fired {{processStrategy.commit()}} → 
{{releaseRetrievedFileResources()}} which closes the 
{{SmbFileClosingInputStream}} (and its underlying SMB file handle). Reading a 
closed stream returns empty.

This is a test issue, not a production bug. In a real route the stream is 
consumed during routing, before on-completion fires.

Fix: move stream reading into a {{process()}} step inside the route where the 
stream is still open, stash the content in a header, and assert the header 
after {{assertIsSatisfied()}}.

> camel-smb - SmbStreamDownloadIT fails with empty body on streamDownload
> -----------------------------------------------------------------------
>
>                 Key: CAMEL-24189
>                 URL: https://issues.apache.org/jira/browse/CAMEL-24189
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-smb
>            Reporter: Claus Ibsen
>            Priority: Major
>              Labels: test-failure
>
> The {{SmbStreamDownloadIT.testStreamDownload}} test fails consistently on 
> main with:
> {code}
> expected: <World\n> but was: <>
> {code}
> When {{streamDownload=true}}, the consumer wraps the SMB file handle in a 
> {{SmbFileClosingInputStream}} and sets it as the exchange body. However, by 
> the time the test reads the {{InputStream}} from the exchange, the stream 
> returns empty content.
> This is a stream lifecycle / timing issue: the underlying SMB file handle is 
> being closed or the stream consumed before the test (or a downstream 
> processor) can read it.
> Note: this is *not* the same class of bug as CAMEL-24088 (FTP 
> streamDownload). The FTP issue was about unchecked null returns and ignored 
> completion status. The SMB code correctly throws {{SMBRuntimeException}} on 
> open failures. The SMB problem is that the stream content is lost between the 
> consumer setting the body and the downstream processor reading it.



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

Reply via email to