If the code called by exec:java misbehaves and executes System.exit(int) instead of simply returning when successful or throwing an exception in case of an error, it not only interrupts the execution of this mojo, but terminates the whole Maven JVM in the middle of a build. In order to not force users to switch to the forking exec:exec goal instead and enable them to stay within the comfort zone of exec:java, I am proposing a special security manager which blocks System.exit(int) execution in favour of
logging the fact that System.exit(0) was called in case of a successfuly execution,
logging + throwing a special SystemExitException with the exit code to handle error situations gracefully and without terminating the Maven JVM.
@slawekjaranowski: As discussed, a corresponding PR for this issue is in the pipeline. I already have an implementation, I just need to write a couple of integration tests on top of it.
Relates to #388, specifically to https://github.com/mojohaus/exec-maven-plugin/issues/388#issuecomment-1801195082.
If the code called by
exec:java
misbehaves and executesSystem.exit(int)
instead of simply returning when successful or throwing an exception in case of an error, it not only interrupts the execution of this mojo, but terminates the whole Maven JVM in the middle of a build. In order to not force users to switch to the forkingexec:exec
goal instead and enable them to stay within the comfort zone ofexec:java
, I am proposing a special security manager which blocksSystem.exit(int)
execution in favour ofSystem.exit(0)
was called in case of a successfuly execution,SystemExitException
with the exit code to handle error situations gracefully and without terminating the Maven JVM.@slawekjaranowski: As discussed, a corresponding PR for this issue is in the pipeline. I already have an implementation, I just need to write a couple of integration tests on top of it.