@Internal public class SafetyNetCloseableRegistry extends AbstractAutoCloseableRegistry<Closeable,WrappingProxyCloseable<? extends Closeable>,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef,IOException>
AbstractAutoCloseableRegistry
registers WrappingProxyCloseable
. When the proxy becomes subject to GC, this registry takes care of
closing unclosed Closeable
s.
Phantom references are used to track when WrappingProxy
s of
Closeable
got GC'ed. We ensure that the wrapped Closeable
is properly closed to
avoid resource leaks.
Other than that, it works like a normal CloseableRegistry
.
All methods in this class are thread-safe.
closeableToRef
Modifier and Type | Method and Description |
---|---|
protected void |
doClose(List<Closeable> toClose)
This implementation doesn't imply any exception during closing due to backward compatibility.
|
protected void |
doRegister(WrappingProxyCloseable<? extends Closeable> wrappingProxyCloseable,
Map<Closeable,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef> closeableMap)
Does the actual registration of the closeable with the registry map.
|
protected boolean |
doUnRegister(WrappingProxyCloseable<? extends Closeable> closeable,
Map<Closeable,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef> closeableMap)
Does the actual un-registration of the closeable from the registry map.
|
close, getNumberOfRegisteredCloseables, getSynchronizationLock, isCloseableRegistered, isClosed, registerCloseable, removeCloseableInternal, unregisterCloseable
protected void doRegister(@Nonnull WrappingProxyCloseable<? extends Closeable> wrappingProxyCloseable, @Nonnull Map<Closeable,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef> closeableMap)
AbstractAutoCloseableRegistry
doRegister
in class AbstractAutoCloseableRegistry<Closeable,WrappingProxyCloseable<? extends Closeable>,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef,IOException>
protected boolean doUnRegister(@Nonnull WrappingProxyCloseable<? extends Closeable> closeable, @Nonnull Map<Closeable,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef> closeableMap)
AbstractAutoCloseableRegistry
doUnRegister
in class AbstractAutoCloseableRegistry<Closeable,WrappingProxyCloseable<? extends Closeable>,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef,IOException>
protected void doClose(List<Closeable> toClose) throws IOException
doClose
in class AbstractAutoCloseableRegistry<Closeable,WrappingProxyCloseable<? extends Closeable>,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef,IOException>
IOException
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.