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

async does not guarantee that JavaFX application is launched #167

Open
Marcono1234 opened this issue Jul 2, 2023 · 0 comments
Open

async does not guarantee that JavaFX application is launched #167

Marcono1234 opened this issue Jul 2, 2023 · 0 comments

Comments

@Marcono1234
Copy link

Version

0.0.8

Description

Apache Commons Exec launches the process in a separate thread (slightly related to EXEC-121), so what could happen is that before the JavaFX process is launched Maven exits.

In reality it is probably rather unlikely that this will happen because that executor thread launches the process as first action and on the other hand it takes some time until the JavaFX plugin and Maven finish and the JVM exits. But it is not impossible that this can occur.
It can for example be demonstrated by running with mvnDebug clean javafx:run "-Djavafx.async=true" "-Djavafx.asyncDestroyOnShutdown=false" and setting a breakpoint in org.apache.commons.exec.DefaultExecutor.executeInternal to pause execution there.

Potential solution

One potential solution might be to add a CountDownLatch or similar with initial value of 1. Then supply a custom ExecuteStreamHandler to exec whose start() method calls countDown(), and additionally in onProcessFailed also call countDown() (to avoid a dead lock in case of a failure).
And then have org.openjfx.JavaFXBaseMojo.executeCommandLine call countDownLatch.await() after calling execute. This should then make sure that the process was launched before the JavaFX plugin (and eventually the JVM) exits.
(Have not tested this though)

As side note: Maybe onProcessFailed in org.openjfx.JavaFXBaseMojo.executeCommandLine should also call psh.stop() to be safe?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant