[
https://issues.apache.org/jira/browse/CAMEL-27067?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-27067:
--------------------------------
Fix Version/s: 4.24.0
> camel-stream - a consumer with scanStream=true and readLine=false reads the
> stream but never routes the data
> ------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27067
> URL: https://issues.apache.org/jira/browse/CAMEL-27067
> Project: Camel
> Issue Type: Bug
> Components: camel-stream
> Reporter: shashank
> Assignee: shashank
> Priority: Major
> Fix For: 4.24.0
>
>
> h3. What happens
> With {{readLine=false}} the stream consumer reads the stream in raw mode
> ({{readFromStreamRawMode}}). Without {{scanStream}} it reads the stream once
> and creates one exchange with the bytes. With {{scanStream=true}} it loops
> and calls {{is.readAllBytes()}} on each scan, but the bytes it read are never
> passed to {{processRaw}}: no exchange is created, and the data is dropped. A
> route such as
> {code}
> from("stream:file?fileName=app.log&scanStream=true&readLine=false")
> .to("mock:result");
> {code}
> consumes the file (and everything appended to it later) and never sends
> anything.
> Also, in this mode a file that does not exist when the consumer starts gives
> a null stream, and the first {{readAllBytes()}} throws a
> {{NullPointerException}} that ends the consumer thread. The line mode handles
> a null reader.
> h3. How to reproduce
> {{ScanStreamFileRawModeTest}} (camel-stream): writes "Hello\nWorld\n" to a
> file, starts
> {{stream:file?...&scanStream=true&scanStreamDelay=100&readLine=false}}, and
> expects one exchange with that text, then appends "Bye\n" and expects a
> second exchange with it. On main no exchange arrives and the test fails after
> 10 seconds.
> h3. Fix
> In the scan loop of the raw mode, route the bytes that were read with
> {{processRaw}} (and keep the index), and reopen the stream for {{retry}} only
> at the end of the stream, as the line mode does (reopening after each read
> would read the same data again). A null stream counts as the end of the
> stream. This also ends a busy loop on main: with
> {{scanStream=true&retry=true}} the raw mode reopened the stream after every
> read and only slept at the end of the stream, so a non-empty file (or URL)
> was read again and again without a pause. With {{retry}} a reopen still
> starts from the beginning of the file, as in the line mode, so
> {{fileWatcher}} is the option to use for a file that grows. Scan exchanges
> carry {{CamelStreamComplete=false}}, as in the line mode. The non-scan raw
> mode now also keeps the index it gets back from {{processRaw}}.
> camel-4.18.x has the same code.
> _Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)