Commit 7348bfe
Fix intermittent ArrayIndexOutOfBoundsException during stderr processing (#303)
* Fix intermittent ArrayIndexOutOfBoundsException during stderr processing
The same StreamConsumer instance was shared between the stdout and stderr
StreamPumper threads in CommandLineUtils.executeCommandLine(). Since
StreamConsumer has non-thread-safe mutable state (StringBuilder, File,
int fields), concurrent access from both threads caused
ArrayIndexOutOfBoundsException inside StringBuilder's System.arraycopy.
Use separate StreamConsumer instances for stdout and stderr to eliminate
the race condition.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Use synchronized on shared StreamConsumer instead of separate instances
Address review feedback: use a single shared StreamConsumer with
synchronized consumeLine() to protect both the consumer's internal
state and the buildContext writes from concurrent access by the
stdout and stderr StreamPumper threads.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 0e0410c commit 7348bfe
1 file changed
Lines changed: 4 additions & 4 deletions
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
553 | 553 | | |
554 | 554 | | |
555 | 555 | | |
556 | | - | |
557 | | - | |
| 556 | + | |
| 557 | + | |
558 | 558 | | |
559 | 559 | | |
560 | 560 | | |
| |||
593 | 593 | | |
594 | 594 | | |
595 | 595 | | |
596 | | - | |
| 596 | + | |
597 | 597 | | |
598 | 598 | | |
599 | 599 | | |
| |||
609 | 609 | | |
610 | 610 | | |
611 | 611 | | |
612 | | - | |
| 612 | + | |
613 | 613 | | |
0 commit comments