@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 Closeables.
Phantom references are used to track when WrappingProxys 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.
| 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, getSynchronizationLock, isCloseableRegistered, isClosed, registerCloseable, removeCloseableInternal, unregisterCloseableprotected void doRegister(@Nonnull WrappingProxyCloseable<? extends Closeable> wrappingProxyCloseable, @Nonnull Map<Closeable,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef> closeableMap)
AbstractCloseableRegistrydoRegister 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)
AbstractCloseableRegistrydoUnRegister in class AbstractCloseableRegistry<WrappingProxyCloseable<? extends Closeable>,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef>public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class AbstractCloseableRegistry<WrappingProxyCloseable<? extends Closeable>,org.apache.flink.core.fs.SafetyNetCloseableRegistry.PhantomDelegatingCloseableRef>IOExceptionCopyright © 2014–2018 The Apache Software Foundation. All rights reserved.