Package org.elasticsearch.test
Class ReachabilityChecker
java.lang.Object
org.elasticsearch.test.ReachabilityChecker
Utility class for checking that objects become unreachable when expected.
Registered objects become unreachable only when the GC notices them. This class attempts to trigger the GC at various points but does not
guarantee a full GC. If we're unlucky, some of these objects may move to old enough heap generations that they are not subject to our GC
attempts, resulting in test flakiness. Time will tell whether this is a problem in practice or not; if it is then we'll have to introduce
some extra measures here.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
From the objects registered since the most recent call toensureUnreachable()
(or since the construction of thisReachabilityChecker
ifensureUnreachable()
has not been called) this method chooses one at random and verifies that it has not yet become unreachable.void
Ensure that all registered objects have become unreachable.<T> T
register
(T target) Register the given target object for reachability checks.
-
Constructor Details
-
ReachabilityChecker
public ReachabilityChecker()
-
-
Method Details
-
register
public <T> T register(T target) Register the given target object for reachability checks.- Returns:
- the given target object.
-
ensureUnreachable
public void ensureUnreachable()Ensure that all registered objects have become unreachable. -
checkReachable
public void checkReachable()From the objects registered since the most recent call toensureUnreachable()
(or since the construction of thisReachabilityChecker
ifensureUnreachable()
has not been called) this method chooses one at random and verifies that it has not yet become unreachable.
-