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

Lingering threads in multiple tests #7319

Open
2 tasks done
aoli-al opened this issue Jul 19, 2024 · 2 comments
Open
2 tasks done

Lingering threads in multiple tests #7319

aoli-al opened this issue Jul 19, 2024 · 2 comments

Comments

@aoli-al
Copy link
Contributor

aoli-al commented Jul 19, 2024

Guava Version

514f212

Description

While running Guava tests, I noticed multiple threads created by different tests that were left open.

Here is the incomplete list:

The thread pool was opened here, but the shutdown was not called.

ExecutorService threadPool = Executors.newFixedThreadPool(nThreads);

In FuturesTest.java, multiple tests call newSingleThreadExecutor() without shutdown.

ListenableFuture<String> futureResult =

In TestThread.java, calling stop() may throw UnsupportedOperationException for the new version of Java. Thus, the join method will not be called. (maybe call interrupt when stop is not available?)

Example

Any test mentioned above.

Expected Behavior

The test should clean up threads.

Actual Behavior

Threads left open.

Packages

No response

Platforms

No response

Checklist

  • I agree to follow the code of conduct.

  • I can reproduce the bug with the latest version of Guava available.

@aoli-al
Copy link
Contributor Author

aoli-al commented Jul 21, 2024

#7320 addresses the lingering threads in CacheBuilderTest and FutureTest; however, the threads in TestThread are still not properly closed.

I tried to call thread.interrupt in TestThread::tearDown, but it does not work for UninterruptibleMonitorTest. Shall I create another issue to track this or just leave this issue open?

@cpovirk
Copy link
Member

cpovirk commented Jul 23, 2024

We probably should use interrupt() so that we at least get rid of the threads from InterruptibleMonitorTest. I think the threads from UninterruptibleMonitorTest are unavoidably stuck under newer versions of Java. That is not great, but it should be mostly harmless, I hope. (If we see bigger problems in the future, we could consider trying to run those tests in a separate VM (which I assume they are not run in currently) or even exclude them entirely from our external CI, leaving them to run internally (assuming that we don't see similar problems there :)).)

We should probably make our tearDown() method catch the UnsupportedOperationException from stop() while we're there. It doesn't fail the test, but it's probably spamming output. (We could still output something to acknowledge what's going on, but we could at least make it shorter than a full stack trace. And we probably don't need to bother at all if we leave a comment.)

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

No branches or pull requests

3 participants