Problem
A caller who forgets to close a response/stream gets no signal until something breaks.
Proposed change
Add an opt-in leak detector that logs a WARN when a closeable becomes phantom-reachable without having been closed. Obtain java.lang.ref.Cleaner reflectively (cached by lazy) so the same Java-8 bytecode uses it on JDK 9+ and no-ops on 8. Reuse the existing closed flag as the "was it closed?" signal. Gate behind a system property; default off. Do not auto-close — detection only (auto-closing a caller-owned resource is the hazard we deliberately avoid).
Prior art: openai-java's PhantomReachable uses the reflective-Cleaner technique (Apache-2.0 — attribute the lifted util).
Acceptance
Priority: low · Effort: medium
Problem
A caller who forgets to close a response/stream gets no signal until something breaks.
Proposed change
Add an opt-in leak detector that logs a WARN when a closeable becomes phantom-reachable without having been closed. Obtain
java.lang.ref.Cleanerreflectively (cachedby lazy) so the same Java-8 bytecode uses it on JDK 9+ and no-ops on 8. Reuse the existingclosedflag as the "was it closed?" signal. Gate behind a system property; default off. Do not auto-close — detection only (auto-closing a caller-owned resource is the hazard we deliberately avoid).Prior art: openai-java's
PhantomReachableuses the reflective-Cleaner technique (Apache-2.0 — attribute the lifted util).Acceptance
Priority: low · Effort: medium