allthingssecurity opened a new pull request, #30465:
URL: https://github.com/apache/camel/pull/30465

   # Description
   
   [CAMEL-27209](https://issues.apache.org/jira/browse/CAMEL-27209)
   
   The `stream` consumer reads in one task on its own thread. With 
`scanStream=true` the task loops for as long as the consumer runs, and with 
`retry=true` it opens the stream again when it ends. For `stream:http` an 
`IOException` ended that task: opening the URL failed (the server could not be 
reached, or answered with an error status such as 503), either at the start of 
a scanning consumer (it does not open the stream in `doStart`, to be lenient) 
or when it opened the stream again after the server closed the response, or 
reading a line failed (the connection was lost in the middle of a response). 
The exception reached the exception handler once, the task ended, and the 
consumer stayed started without reading anything until the route was restarted. 
A server restart or a short network outage was enough.
   
   Fix (scan mode only, `StreamConsumer`):
   - A stream that cannot be opened is reported and gives `null`, as a file 
that does not exist yet already does, so the scan opens it again later 
(`retry=true`) instead of ending.
   - A line that cannot be read ends the stream: it is reported and, with 
`retry=true`, opened again.
   - The first failure in a row goes to the exception handler; the next ones 
are logged at DEBUG, and an INFO line says when the stream could be opened 
again.
   - After a failure the scan waits at least one second (or `scanStreamDelay` 
if longer) before the next attempt, so a server that is down is not asked in a 
loop (`scanStreamDelay` defaults to 0).
   - Without `retry` a failed stream behaves like a stream that ended (not 
opened again), as before for the end of the stream; the message says that 
`retry` opens it again.
   - The consumer that does not scan is unchanged (it opens the stream in 
`doStart`, so a failure fails the start).
   
   Not changed: the raw mode (`readLine=false`) still ignores a read error and 
treats it as the end of the stream (only its re-open gets the same handling). 
`stream:file` already treated a missing file as "not there yet".
   
   Tests: `StreamHttpScanRetryTest` (a minimal HTTP server on a `ServerSocket`, 
one answer per connection): the server answers, fails the next request with 
503, then answers again (line and raw mode); fails the first request, then 
answers (the consumer starts while the server is down); and resets the 
connection in the middle of a body, then answers again (a read fails). Runs: 
the four tests fail on main (the reading thread ends, nothing is routed after 
the failure) and pass with the fix; camel-stream module tests 37 run, 0 
failures (1 skipped, as on main); the new test class 20 times in one JVM: 80 of 
80.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it): 
[CAMEL-27209](https://issues.apache.org/jira/browse/CAMEL-27209).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
     (I built the core modules and camel-stream with the formatter and 
import-sort plugins. No option or doc changed. I did not run the full root 
build.)
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
     This PR was prepared with Claude Code (Claude Opus 5.5). The commit 
carries a `Co-Authored-By` trailer.
   
   _Claude Code on behalf of allthingssecurity_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to