davsclaus commented on code in PR #27931:
URL: https://github.com/apache/camel/pull/27931#discussion_r4290651433
##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/AiCliCommandExecutor.java:
##########
@@ -110,7 +107,7 @@ private void execute(ActiveCommand command) {
int exitCode = 1;
boolean interrupted = false;
try {
- synchronized (CamelJBangMain.class) {
+ synchronized (CliRunner.LOCK) {
Review Comment:
Keeping it: the outer lock is not only around `CliRunner.run`. The default
invoker (`invoke`) first switches the selected process
(`EnvironmentHelper.setSelectedProcess`, static state that `camel cmd send`
reads) and restores it afterwards. Holding the lock across the switch, the
command and the restore makes them one unit; without it, a command of `camel
ask` or the camel shell could run in between with the selected process of the
AI panel. The inner acquisition in `CliRunner` is reentrant. It is also what
`AiCliCommandExecutorTest` relies on when it holds the lock to keep a command
waiting.
(For the record, `stillRunning()` and `STOP_GRACE_MILLIS` are in
ee4b692129e5, with the test of a command that ignores the interrupt.)
_Claude Code on behalf of davsclaus_
--
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]