@Internal public class SafetyNetCloseableRegistry extends AbstractCloseableRegistry<WrappingProxyCloseable<? extends Closeable>,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef>
AbstractCloseableRegistry
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 |
---|---|
void |
close() |
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.
|
addCloseableInternal, getNumberOfRegisteredCloseables, getReferencesToClose, 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)
AbstractCloseableRegistry
doRegister
in class AbstractCloseableRegistry<WrappingProxyCloseable<? extends Closeable>,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef>
protected boolean doUnRegister(@Nonnull WrappingProxyCloseable<? extends Closeable> closeable, @Nonnull Map<Closeable,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef> closeableMap)
AbstractCloseableRegistry
doUnRegister
in class AbstractCloseableRegistry<WrappingProxyCloseable<? extends Closeable>,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef>
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class AbstractCloseableRegistry<WrappingProxyCloseable<? extends Closeable>,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef>
IOException
Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.