FrankChen021 opened a new pull request, #20317:
URL: https://github.com/apache/druid/pull/20317
Related to #20312 (item 2).
### Description
`ReferenceCountingResourceHolderTest.testResourceHandlerClearedByJVM` fails
intermittently on master with:
```
expected: <1> but was: <3>
at
ReferenceCountingResourceHolderTest.verifyCleanerRun(ReferenceCountingResourceHolderTest.java:126)
```
Example:
https://github.com/apache/druid/actions/runs/34432737655/job/102731457738.
`ReferenceCountingResourceHolder.LEAKED_RESOURCES` is a JVM-global counter,
and surefire runs with `reuseForks=true`. `verifyCleanerRun` loops on
`System.gc()` until the counter changes and then asserts an exact `+1`. Holders
leaked by other test classes in the same fork are collected by the same forced
GC, so the delta can be larger than 1. Because the counter is incremented
*before* the closer runs, the loop can also exit before this test's own closer
has executed, which would make the `released` assertion fail too.
#### Changes
* Loop until this test's own `released` flag is set, which is the completion
signal that belongs to this test.
* Assert `released`, and only assert a lower bound (`>= initial + 1`) on the
global counter.
Verified locally with `mvn -pl processing test
-Dtest=ReferenceCountingResourceHolderTest` (3 tests pass).
<hr>
##### Key changed/added classes in this PR
* `ReferenceCountingResourceHolderTest`
<hr>
This PR has:
- [x] been self-reviewed.
- [x] added or updated unit tests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]