public abstract class AbstractCloseable extends Object implements ReferenceOwner, ManagedCloseable
| Modifier and Type | Field and Description |
|---|---|
protected StackTrace |
closedHere |
protected static boolean |
DISABLE_DISCARD_WARNING |
protected static boolean |
DISABLE_THREAD_SAFETY |
protected static boolean |
STRICT_DISCARD_WARNING |
protected static long |
WARN_NS |
INIT, TMP| Modifier | Constructor and Description |
|---|---|
protected |
AbstractCloseable() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
assertCloseable()
Asserts that this resource can be closed, throwing an
IllegalStateException if it cannot. |
static void |
assertCloseablesClosed() |
void |
clearUsedByThread() |
void |
close()
Closes this resource, potentially preventing parts of it from being used again
and potentially relinquishing resources held.
|
StackTrace |
createdHere() |
static void |
disableCloseableTracing() |
boolean |
disableThreadSafetyCheck() |
AbstractCloseable |
disableThreadSafetyCheck(boolean disableThreadSafetyCheck) |
static void |
enableCloseableTracing() |
static void |
gcAndWaitForCloseablesToClose() |
boolean |
isClosed()
Is this object closed
|
boolean |
isClosing()
Is this object closed, or in the process of closing
|
protected boolean |
isInUserThread() |
protected abstract void |
performClose()
Call close() to ensure this is called exactly once.
|
int |
referenceId() |
void |
resetUsedByThread() |
protected boolean |
shouldPerformCloseInBackground() |
protected boolean |
shouldWaitForClosed() |
protected void |
threadSafetyCheck(boolean isUsed) |
void |
throwExceptionIfClosed()
Called when a resources needs to be open to use it.
|
void |
throwExceptionIfClosedInSetter() |
String |
toString() |
static void |
unmonitor(Closeable closeable) |
static boolean |
waitForCloseablesToClose(long millis) |
protected void |
waitForClosed() |
void |
warnAndCloseIfNotClosed()
Called from finalise() implementations.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitreferenceName, temporarycloseQuietly, closeQuietlyprotected static final boolean DISABLE_THREAD_SAFETY
protected static final boolean DISABLE_DISCARD_WARNING
protected static final boolean STRICT_DISCARD_WARNING
protected static final long WARN_NS
protected transient volatile StackTrace closedHere
public static void enableCloseableTracing()
public static void disableCloseableTracing()
public static void gcAndWaitForCloseablesToClose()
public static boolean waitForCloseablesToClose(long millis)
public static void assertCloseablesClosed()
public static void unmonitor(Closeable closeable)
public int referenceId()
referenceId in interface ReferenceOwnerpublic StackTrace createdHere()
createdHere in interface ManagedCloseablepublic final void close()
CloseableThis method is idem-potent.
close in interface Closeableclose in interface AutoCloseableprotected void assertCloseable()
IllegalStateException if it cannot.
This can be useful for resources that have outstanding guarantees such as acquired update locks or open contexts.
Electing to throw an Exception might cause memory-leaks as there is no guarantee that the close methods will ever be invoked again in the general case.
IllegalStateException - if the resource cannot be closed.protected boolean isInUserThread()
protected void waitForClosed()
public void throwExceptionIfClosed()
throws IllegalStateException
throwExceptionIfClosed in interface ManagedCloseableClosedIllegalStateException - if closedIllegalStateException - if the thread safety check failspublic void throwExceptionIfClosedInSetter()
throws IllegalStateException
IllegalStateExceptionpublic void warnAndCloseIfNotClosed()
warnAndCloseIfNotClosed in interface ManagedCloseableprotected abstract void performClose()
throws IllegalStateException
IllegalStateExceptionpublic boolean isClosing()
QueryCloseable
This should always be true if QueryCloseable.isClosed() is true
isClosing in interface QueryCloseablepublic boolean isClosed()
QueryCloseableisClosed in interface QueryCloseableprotected boolean shouldPerformCloseInBackground()
protected boolean shouldWaitForClosed()
protected void threadSafetyCheck(boolean isUsed)
throws IllegalStateException
IllegalStateExceptionpublic void resetUsedByThread()
public void clearUsedByThread()
public boolean disableThreadSafetyCheck()
public AbstractCloseable disableThreadSafetyCheck(boolean disableThreadSafetyCheck)
Copyright © 2022. All rights reserved.