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

(bug) Cleanup hangs when FX Application Thread got killed #287

Closed
Ortner opened this issue May 27, 2016 · 5 comments · Fixed by #288
Closed

(bug) Cleanup hangs when FX Application Thread got killed #287

Ortner opened this issue May 27, 2016 · 5 comments · Fixed by #288

Comments

@Ortner
Copy link
Contributor

Ortner commented May 27, 2016

Issue

The Cleanup is called in the after method of JUnit tests. If the FX Application Thread is beeing killed during the test, the call to the clean up method cleanupApplication() in FXToolkit waiting for the cleanup to be performed on the FX Application Thread.

Solution

Detect, if the Application thread is running, before doing the cleanup.

Ortner pushed a commit to Ortner/TestFX that referenced this issue May 27, 2016
Task-Url: http://github.com/TestFX/TestFX/issues/issue/287

Added method to detect whether FX Application Thread is running. Clean
up code is only pushed  on the FX-Thread if it is running.

fixes TestFX#287
fixes TestFX#247
@hastebrot
Copy link
Member

In general the FX Thread is killed by using Platform.exit(), which is also implicitely called when the last Window or Stage was closed (TestFX prevents this by using Platform.setImplicitExit(false)).

I think the easiest way it to retrieve the FX Thread from Set<Thread> threadSet = Thread.getAllStackTraces().keySet();, check if it is running, otherwise throw an exception.

@hastebrot
Copy link
Member

Oh, you already implemented it. 👍

@Ortner
Copy link
Contributor Author

Ortner commented May 27, 2016

Yes. I do cancel the future, so feedback is passed this way.

I do have the problem, with headless tests. If the Platform has an exception during start up:

java.lang.ClassNotFoundException: com.sun.glass.ui.monocle.MonoclePlatformFactory
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at com.sun.glass.ui.PlatformFactory.getPlatformFactory(PlatformFactory.java:42)
    at com.sun.glass.ui.Application.run(Application.java:146)
    at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:257)
    at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:211)
    at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:675)
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:695)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)

It hangs up during cleanup, as JUnit tears down after the Exception.

Using frambuffer on my build server it also hangs (not on my machine with the same docker image?!).

@mjmaix
Copy link

mjmaix commented Jun 20, 2016

thanks ortner this helped me

@Ortner
Copy link
Contributor Author

Ortner commented Jun 20, 2016

Oh, thanks for the feedback. Always good to hear, that this fix helps others too.

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

Successfully merging a pull request may close this issue.

3 participants