Class OpenSslEngineMap
- java.lang.Object
-
- io.netty.handler.ssl.OpenSslEngineMap
-
final class OpenSslEngineMap extends java.lang.ObjectMaps a nativeSSL*pointer to itsReferenceCountedOpenSslEngineso native OpenSSL callbacks (certificate verification, private-key operations, certificate (de)compression) can recover the engine from the raw pointer they are handed.Engines are held weakly so a leaked engine is not pinned by the long-lived parent
ReferenceCountedOpenSslContext(a live engine is always strongly reachable via itsSslHandler, and on the stack during a callback, so weak retention never collects a usable one). ForSslProvider.OPENSSLthis letsOpenSslEngine.finalize()reclaim the nativeSSL*without waiting for the whole context to be collected; a leakedSslProvider.OPENSSL_REFCNTengine has no finalizer so its native memory still leaks, but it becomes collectable and so is reported by theResourceLeakDetectorrather than pinned silently.Entries are removed in
ReferenceCountedOpenSslEngine.shutdown(), so the map does not grow in steady state. A clearedWeakReferencelingers only for a leakedOPENSSL_REFCNTengine (whoseSSL*is never freed, hence never reused); such a husk is tiny, dwarfed by the native memory it marks, and is deliberately left as a heap-inspectable leak signal. Do not reap it (e.g. via aReferenceQueue):get(long)already yieldsnullfor a cleared reference, so reaping would only erase that signal.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.Long,java.lang.ref.WeakReference<ReferenceCountedOpenSslEngine>>engines
-
Constructor Summary
Constructors Constructor Description OpenSslEngineMap()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidadd(long ssl, ReferenceCountedOpenSslEngine engine)(package private) ReferenceCountedOpenSslEngineget(long ssl)(package private) voidremove(long ssl)
-
-
-
Field Detail
-
engines
private final java.util.Map<java.lang.Long,java.lang.ref.WeakReference<ReferenceCountedOpenSslEngine>> engines
-
-
Method Detail
-
add
void add(long ssl, ReferenceCountedOpenSslEngine engine)
-
remove
void remove(long ssl)
-
get
ReferenceCountedOpenSslEngine get(long ssl)
-
-