CloseWatcher

A phantom reference to watch for unclosed objects.

Methods
static CloseWatcher pollUnclosed()
Check for an collected object.
static CloseWatcher pollUnclosed()
Check for an collected object.
Returns:
the first watcher
static CloseWatcher register(Object o, Closeable closeable, boolean stackTrace)
Register an object.
static CloseWatcher register(Object o, Closeable closeable, boolean stackTrace)
Register an object. Before calling this method, pollUnclosed() should be called in a loop to remove old references.
Parameters:
o - the object
closeable - the object to close
stackTrace - whether the stack trace should be registered (this is relatively slow)
Returns:
the close watcher
static void unregister(CloseWatcher w)
Unregister an object, so it is no longer tracked.
static void unregister(CloseWatcher w)
Unregister an object, so it is no longer tracked.
Parameters:
w - the reference
Closeable getCloseable()
Closeable getCloseable()
String getOpenStackTrace()
Get the open stack trace or null if none.
String getOpenStackTrace()
Get the open stack trace or null if none.
Returns:
the open stack trace