[
https://issues.apache.org/jira/browse/CAMEL-27638?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-27638:
--------------------------------
Fix Version/s: 4.25.0
(was: 4.24.0)
> camel-stream: groupLines, fileWatcher, scan without retry, httpHeaders,
> readTimeout bugs
> ----------------------------------------------------------------------------------------
>
> Key: CAMEL-27638
> URL: https://issues.apache.org/jira/browse/CAMEL-27638
> Project: Camel
> Issue Type: Bug
> Components: camel-stream
> Reporter: Claus Ibsen
> Priority: Minor
> Fix For: 4.25.0
>
>
> Found while improving the option descriptions of camel-stream for CAMEL-23832
> (PR https://github.com/apache/camel/pull/30977).
> These are separate problems of the component; the descriptions PR only
> documents the current behavior.
> h4. 1. groupLines has no effect for stream:in
> In {{StreamConsumer.readFromStreamLineMode()}} (without {{scanStream}}) each
> line is passed to {{processLine(line, last, index)}} with {{last =
> readAhead(br) == null}}. {{StreamConsumer.readAhead()}} always returns null
> for kind {{in}}, so every line from System.in is marked as the last one.
> {{processLine()}} then flushes the group at once, so with {{groupLines=10}}
> the user still gets one exchange per line, each with
> {{CamelStreamComplete=true}}.
> Proposed change: for kind {{in}}, do not treat "no read ahead" as the end of
> the stream; flush a group only when it is full or at the real end of the
> stream.
> h4. 2. fileWatcher does nothing when fileName has no directory part
> {{StreamConsumer.doStart()}} passes {{new
> File(endpoint.getFileName()).getParent()}} to {{FileWatcherStrategy}}. For a
> relative name such as {{fileName=app.log}} this is null, and
> {{FileWatcherStrategy.doStart()}} returns without watching anything. With
> {{scanStream=true&retry=true&fileWatcher=true}} the consumer then waits for a
> change event that never comes, so the file is never opened again after a
> rollover. The user sees no error or warning.
> Proposed change: use the parent of the absolute file
> ({{getAbsoluteFile().getParentFile()}}), or at least log a WARN when there is
> no directory to watch.
> h4. 3. scanStream without retry never reads a file that is created after the
> start
> With {{scanStream=true}}, {{StreamConsumer.resolveStreamFromFile()}} returns
> null when the file cannot be read yet. In {{readFromStreamLineMode()}} and
> {{readFromStreamRawMode()}} the stream is only opened again when
> {{retry=true}}, so without {{retry}} the consumer keeps scanning a null
> stream and never reads the file, even after it is created. The user sees a
> started consumer that does nothing, with no log message.
> Proposed change: open the stream again while it is still null, also without
> {{retry}}, or log a WARN that the file does not exist and {{retry}} is needed.
> h4. 4. httpHeaders drops or cuts off header values that contain =, : or a
> comma
> {{StreamConsumer.parseHeaders()}} splits the option on {{,}} and then each
> part on {{[=:]}}, and keeps only parts with exactly two pieces. A header such
> as {{Referer:http://host/path}} has three pieces and is dropped without a
> warning. A value with a comma is cut at the comma, and a value that ends with
> {{=}} (such as a Base64 token) loses its trailing {{=}} because
> {{String.split}} drops the trailing empty strings.
> Proposed change: split each part only on the first {{=}} or {{:}}
> ({{split("[=:]", 2)}}), and log a WARN for a part that is skipped.
> h4. 5. The http consumer ignores the encoding option
> {{StreamConsumer.initializeStreamLineMode()}} reads kind {{http}} with {{new
> InputStreamReader(inputStream)}}, which uses the JVM default charset, while
> kinds {{in}} and {{file}} use {{endpoint.getCharset()}}. Setting
> {{encoding=UTF-8}} has no effect on {{stream:http}}.
> Proposed change: use the configured charset for kind {{http}} too, or the
> charset from the Content-Type of the response when {{encoding}} is not set.
> h4. 6. The readTimeout option does nothing
> {{StreamEndpoint.readTimeout}} has a getter and a setter, but no code reads
> it. It was added for the {{url}} kind (CAMEL-12567), which CAMEL-14167
> removed. {{StreamConsumer.resolveStreamFromUrl()}} does not call
> {{URLConnection.setReadTimeout()}}, so a {{stream:http}} consumer can block
> forever on a server that stops sending data.
> Proposed change: apply it in {{resolveStreamFromUrl()}} (and add a connect
> timeout), or deprecate and remove the option.
> h4. 7. The stream header of kind header is not documented as a header
> {{StreamProducer.resolveStreamFromHeader()}} reads the
> {{java.io.OutputStream}} to write to from the message header {{stream}}, but
> {{StreamConstants}} has no constant for it. The header is therefore missing
> from the header table of the doc page and from the catalog; only the doc text
> names it.
> Proposed change: add a {{@Metadata(label = "producer")}} constant for the
> {{stream}} header to {{StreamConstants}}.
> _Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)