public final class CloseableUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
add(Closeable closeable)
Adds a closeable resource to the set of tracked resources.
|
static void |
assertCloseablesClosed()
Asserts that all closeable resources are closed.
|
static String |
asString(Object id) |
static void |
closeQuietly(Object... closeables)
Close a closeable quietly, i.e.
|
static void |
disableCloseableTracing()
Disables tracing of closeable resources.
|
static void |
enableCloseableTracing()
Enables tracing of closeable resources.
|
static void |
gcAndWaitForCloseablesToClose()
Performs garbage collection and waits for closeables to close.
|
static void |
unmonitor(Closeable closeable) |
static boolean |
waitForCloseablesToClose(long millis)
Waits for closeable resources to close within a specified time limit.
|
public static void add(Closeable closeable)
closeable - The closeable resource to add.public static void enableCloseableTracing()
public static void disableCloseableTracing()
public static void gcAndWaitForCloseablesToClose()
AssertionError - If the finalizer does not complete within the specified timeout.public static boolean waitForCloseablesToClose(long millis)
millis - The time limit in milliseconds to wait for the closeable resources to close.public static void assertCloseablesClosed()
public static void unmonitor(Closeable closeable)
closeable - to remove monitoring ofpublic static void closeQuietly(@Nullable
Object... closeables)
closeables - the objects to closeCopyright © 2023. All rights reserved.