elharo opened a new issue, #205: URL: https://github.com/apache/maven-script-interpreter/issues/205
**Describe the bug** Script evaluation redirects the JVM-global standard streams, and script execution is serialized behind a `static` lock to keep that redirection safe. Both have process-wide side effects. The BeanShell and Groovy interpreters call `System.setOut`/`System.setErr` for the whole JVM during evaluation (BeanShellScriptInterpreter.java:108-158, GroovyScriptInterpreter.java:96-123). While a script runs: - output written to `System.out`/`System.err` by **unrelated threads** in the same JVM (e.g. a logger writing to stderr, parallel build code) is silently captured into the script log; and - a concurrently running script on another thread would otherwise clobber the redirected stream. `ScriptRunner` guards against concurrent evaluation with a **`static` lock** (ScriptRunner.java:43, used at ScriptRunner.java:225). Consequences: 1. All `run(...)` calls across **all** `ScriptRunner` instances in the JVM are serialized, which is a bottleneck for parallel/CI builds that run hook scripts in multiple modules simultaneously. 2. Correctness of the global stream redirection depends entirely on every caller routing evaluation through that single static lock. Any future code path (or a caller invoking an interpreter directly) that evaluates outside the lock silently reintroduces cross-thread stream corruption. **Eclipse/Maven environment** parallel builds; maven-script-interpreter 1.9-SNAPSHOT. **Expected behavior** Script output redirection affects only the current evaluation; unrelated threads keep writing to their own stdout/stderr, and concurrent script runs in the same JVM do not interfere. **Actual behavior** - JVM-wide `System.out`/`System.err` redirection during evaluation captures other threads' output into the script log. - A single static lock serializes every `ScriptRunner.run(...)` call JVM-wide. **Suggested approach** - Use a per-instance lock instead of the static lock so independent `ScriptRunner` instances do not serialize each other. - Redirect output via a stream that dispatches on the current thread/task (e.g. a `ThreadLocal`-based `OutputStream`) rather than mutating the process-global standard streams; restore the originals exactly as today in a `finally` block. -- 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]
