-
Notifications
You must be signed in to change notification settings - Fork 2
fix(sdk): improve http client shutdown and resource management #319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Scott Hamrick <2623452+cshamrick@users.noreply.github.com>
Summary of ChangesHello @cshamrick, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses resource management and efficiency within the SDK by refactoring the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request is a valuable improvement, refactoring the SDK to use a single shared OkHttpClient instance. This correctly addresses a resource leak in getAuthInterceptor and improves overall efficiency by reusing connection and thread pools. My main feedback concerns a subtle lifecycle management issue introduced by this change. While the OkHttpClient is now correctly shared, the KASClient still attempts to manage its lifecycle in its close() method, leading to redundant shutdown operations. I've left a specific comment on how to address this to ensure clear ownership and prevent potential issues.
Signed-off-by: Scott Hamrick <2623452+cshamrick@users.noreply.github.com>
X-Test Failure Report |
|
@gemini-code-assist review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request effectively addresses a resource leak and improves efficiency by refactoring the SDK to use a single, shared OkHttpClient instance. The changes correctly centralize the client's creation and lifecycle management within SDKBuilder, and propagate the shared client to getAuthInterceptor and getKASClient. The implementation is solid and achieves the stated goals. I have one minor suggestion for code cleanup.
X-Test Results✅ go-v0.4.34 |
Signed-off-by: Scott Hamrick <2623452+cshamrick@users.noreply.github.com>
X-Test Results✅ go-v0.4.34 |
|
X-Test Results✅ js-v0.4.34 |



Refactors SDKBuilder to use a single, shared OkHttpClient instance across its operations.
Previously:
getAuthInterceptormethod created a dedicated OkHttpClient which was never closed, leading to a resource leak.This change:
getAuthInterceptorandgetKASClientto accept and utilize a shared OkHttpClient instance.getAuthInterceptorby ensuring the shared client is properly closed with the SDK.