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

Thread left running #69

Closed
jschneider opened this issue Jan 10, 2017 · 4 comments
Closed

Thread left running #69

jschneider opened this issue Jan 10, 2017 · 4 comments

Comments

@jschneider
Copy link

This simple test case, leaves a thread running:

@test
public void checkThreadsLeft() throws Exception {
await("asdf").until(() -> true);
}

Stack trace of the thread that has been left:

Thread[Thread-0,5,main]
at java.lang.Thread.sleep(Native Method)
at org.awaitility.core.ConditionAwaiter$1.run(ConditionAwaiter.java:163)
at java.lang.Thread.run(Thread.java:745)

Is there a way to terminate this thread?

@jschneider
Copy link
Author

After a little bit of debugging this is what I found out:

In
org.awaitility.core.ConditionAwaiter#await
the executor is shut down and then there is a wait time of 1 sec.
Only after that shutdownNow() is called.

What should/could be done:

  • immediately call shutdownNow()
  • or at least add awaitTermination() after the call to shutdownNow().

@johanhaleby
Copy link
Collaborator

Thanks for the investigation and reporting. I've tried sleeping after "shutdownNow", please try if this alleviates the problem by using version 2.0.1-SNAPSHOT after having added the following maven repo:

<repositories>
        <repository>
            <id>sonatype</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
            <snapshots />
        </repository>
</repositories>

@jschneider
Copy link
Author

In version 3.0.0-rc1 the problem still exists:

Thread[awaitility-poll-scheduling,5,main]
at java.lang.Thread.sleep(Native Method)
at org.awaitility.core.ConditionAwaiter$1.run(ConditionAwaiter.java:172)
at java.lang.Thread.run(Thread.java:745)

@johanhaleby
Copy link
Collaborator

Thanks for trying it out

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

2 participants