Class OpenSslEngineMap
SSL* pointer to its ReferenceCountedOpenSslEngine so 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 its SslHandler, and
on the stack during a callback, so weak retention never collects a usable one). For SslProvider.OPENSSL
this lets OpenSslEngine.finalize() reclaim the native SSL* without waiting for the whole context to
be collected; a leaked SslProvider.OPENSSL_REFCNT engine has no finalizer so its native memory still leaks,
but it becomes collectable and so is reported by the ResourceLeakDetector rather than pinned silently.
Entries are removed in ReferenceCountedOpenSslEngine.shutdown(), so the map does not grow in steady state.
A cleared WeakReference lingers only for a leaked OPENSSL_REFCNT engine (whose SSL* 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 a ReferenceQueue): get(long) already
yields null for a cleared reference, so reaping would only erase that signal.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<Long, WeakReference<ReferenceCountedOpenSslEngine>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidadd(long ssl, ReferenceCountedOpenSslEngine engine) (package private) ReferenceCountedOpenSslEngineget(long ssl) (package private) voidremove(long ssl)
-
Field Details
-
engines
-
-
Constructor Details
-
OpenSslEngineMap
OpenSslEngineMap()
-
-
Method Details
-
add
-
remove
void remove(long ssl) -
get
-