davsclaus opened a new pull request, #30122:
URL: https://github.com/apache/camel/pull/30122
## What
`camel debug` reads the stdout and stderr of the integration it spawned all
the time, on threads that end at the end of the stream. Before this change:
- **100% CPU after the integration ended.** When `readLine()` returned null,
`doReadLog` broke out of the inner loop and then wrapped the ended stream in a
new reader, until the user quit.
- **The integration could block on a full pipe.** stderr was read only after
the integration exited, and with `--log-lines=0` stdout was never read. An
integration that wrote more than the OS pipe holds (64 KB on macOS and Linux)
blocked on its next write, and the debugger stopped with it.
- The log buffer was an `ArrayList` that the reader thread wrote while the
screen thread read it.
## How
- New package-private `OutputTail` reads a stream on a daemon thread until
it ends, and keeps the last N lines (synchronized, and returns a copy for
reading).
- `Debug` reads stdout (last 100 lines) and stderr (last 1000 lines) with it
as soon as the integration is spawned, whatever `--log-lines` is. When the
integration has ended, it waits up to 2 s for the rest of the output and prints
the last lines of both, as before.
This is item 6 of CAMEL-27004 (split from CAMEL-26914). The other items of
that ticket are not part of this PR.
## Tests
- `OutputTailTest`:
- keeps the last lines
- the thread ends at the end of the stream and doesn't read it again
- a real `sh` child that writes about 1 MB to both stdout and stderr exits
within the timeout while both are read (disabled on Windows)
- `DebugCommandTest` and `DebugRunArgumentsTest` still pass, and so does the
full `camel-jbang-core` suite.
_Claude Code on behalf of Claus Ibsen (davsclaus)_
🤖 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]