Keep reference to leaked scope to make sure GC detection doesn't kick in first. (#2972)

This commit is contained in:
Anuraag Agrawal 2021-03-04 00:52:07 +09:00 committed by GitHub
parent 9997dee68e
commit 62cfc060d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -141,7 +141,8 @@ class StrictContextStorageTest {
@SuppressWarnings("ReturnValueIgnored")
void decorator_close_withLeakedScope(Supplier<Scope> method, String methodName) throws Exception {
Thread thread = new Thread(method::get);
AtomicReference<Scope> scope = new AtomicReference<>();
Thread thread = new Thread(() -> scope.set(method.get()));
thread.setName("t1");
thread.start();
thread.join();