You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] [JAVA] HttpClient memberVarHttpClient not closed #24942
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I noticed that the XxxApi.java file generated when using library=native calls apiClient.getHttpClient() and stores the resulting HttpClient in a private field, but never calls .close() on it. (This class was made AutoCloseable in Java 21, and closing it is important to release resources.) Clients of the library could not easily work around this; they would have to pass in a special HttpClient.Builder which tracked all the times .build() was called, and retain weak references so they could be closed later.
Expected: some call to memberVarHttpClient.close(). Actual: none, just created and then used to make requests.
NOTE: I tried to reproduce in trunk (f99cf3b) but compilation failed for some apparently unrelated reason: missing Enum.java. (Bisected this to #24812.) OriginServiceApi.java was still generated the same way, still compilable, still missing .close().
Related issues/PRs
(none found)
Suggest a fix
Whatever template change would effect
116,116c116,116< public class OriginServiceApi {---> public class OriginServiceApi implements AutoCloseable {158a159,162> @Override> public void close() {> memberVarHttpClient.close();> }
Activity