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

Pause object has a static ExecutorService that can't be shutdown #268

Open
henri-tremblay opened this issue Jun 17, 2022 · 0 comments
Open

Comments

@henri-tremblay
Copy link

org.assertj.swing.timing.Pause has an ExecutorService. It's static and cannot be closed. It means that we have non-daemon threads hanging in there and preventing the JVM to finish.

An example is

    public static void main(String[] args) throws Exception {
        Pause.pause(new Condition("Cond") {
            @Override
            public boolean test() {
                return true;
            }
        });

        Field field = Pause.class.getDeclaredField("EXECUTOR_SERVICE");
        field.setAccessible(true);
        ExecutorService service = (ExecutorService) field.get(null);
        service.shutdownNow();
    }

Without the reflection code at the end, it won't exit for a while.

The easiest solution is to add a static close() method to shutdown the pool. But I think the best is to change the code to rely on the commonPool, e.g. ForkJoinPool.commonPool().submit() or a CompletableFuture.

henri-tremblay added a commit to henri-tremblay/assertj-swing that referenced this issue Jul 2, 2022
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