Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New option 'blockSystemExit' for 'java' mojo #389

Closed
kriegaex opened this issue Nov 9, 2023 · 0 comments · Fixed by #390
Closed

New option 'blockSystemExit' for 'java' mojo #389

kriegaex opened this issue Nov 9, 2023 · 0 comments · Fixed by #390

Comments

@kriegaex
Copy link
Contributor

kriegaex commented Nov 9, 2023

Relates to #388, specifically to #388 (comment).

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.

kriegaex added a commit to kriegaex/exec-maven-plugin that referenced this issue Nov 9, 2023
This new option enables users to stop programs called by 'exec:java'
from calling System::exit, terminating not just the mojo but the whole
Maven JVM.

Closes mojohaus#389.
Relates to mojohaus#388.
kriegaex added a commit to kriegaex/exec-maven-plugin that referenced this issue Nov 9, 2023
This new option enables users to stop programs called by 'exec:java'
from calling System::exit, terminating not just the mojo but the whole
Maven JVM.

Closes mojohaus#389.
Relates to mojohaus#388.
kriegaex added a commit to kriegaex/exec-maven-plugin that referenced this issue Nov 9, 2023
This new option enables users to stop programs called by 'exec:java'
from calling System::exit, terminating not just the mojo but the whole
Maven JVM.

Closes mojohaus#389.
Relates to mojohaus#388.
kriegaex added a commit to kriegaex/exec-maven-plugin that referenced this issue Nov 10, 2023
This new option enables users to stop programs called by 'exec:java'
from calling System::exit, terminating not just the mojo but the whole
Maven JVM.

Closes mojohaus#389.
Relates to mojohaus#388.
kriegaex added a commit to kriegaex/exec-maven-plugin that referenced this issue Nov 10, 2023
This new option enables users to stop programs called by 'exec:java'
from calling System::exit, terminating not just the mojo but the whole
Maven JVM.

Closes mojohaus#389.
Relates to mojohaus#388.
slawekjaranowski pushed a commit that referenced this issue Nov 10, 2023
This new option enables users to stop programs called by 'exec:java'
from calling System::exit, terminating not just the mojo but the whole
Maven JVM.

Closes #389.
Relates to #388.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants