public interface ManagedCloseable extends Closeable
Closeable.
Implementations may inspect their creation site and warn when discarded
without being closed. Users typically interact with such resources via
try-with-resources.
Thread safety is left to the concrete implementation.
| Modifier and Type | Method and Description |
|---|---|
default StackTrace |
createdHere()
Returns the stack trace of the location where the resource was created.
|
default void |
throwExceptionIfClosed()
Throws an exception if the resource is closed or in the process of closing.
|
default void |
warnAndCloseIfNotClosed()
Closes the resource if it is not already closed, and logs a warning if the resource was discarded without being closed.
|
close, closeQuietly, closeQuietlyisClosed, isClosingdefault void warnAndCloseIfNotClosed()
When resource tracing is enabled and discard warnings are not disabled, a warning message is logged indicating that the resource was discarded without being properly closed. The resource is then closed quietly, meaning that no exception is thrown if an error occurs during the closing process.
default void throwExceptionIfClosed()
throws ClosedIllegalStateException,
ThreadingIllegalStateException
If the resource is in the process of closing, a ClosedIllegalStateException is thrown.
The exception message indicates whether the resource is already closed or is currently in the process of closing.
ClosedIllegalStateException - If the resource has been released or closed.ThreadingIllegalStateException - If the thread safety check fails.default StackTrace createdHere()
By default, this method returns null, indicating that the information is not available.
Implementations may override this method to provide the actual stack trace where the resource was created.
null if the information is not available.Copyright © 2026 Chronicle Software Ltd. All rights reserved.