openfga / sdk-generator

OpenFGA Client SDK Generator
Apache License 2.0
14 stars 30 forks source link

fix(java-sdk): don't create a new HttpClient on every request #287

Closed jimmyjames closed 5 months ago

jimmyjames commented 5 months ago

Fixes issue of creating a new HttpClient on every request.

Description

As noted in https://github.com/openfga/java-sdk/issues/46, we are currently creating a new HttpClient on every request. This change fixes that by building the client when the ApiClient is instantiated, and if the HttpClient.Builder is updated.

Note that this change does not address the retry case, in which we create a new HttpClient with a delayed executor. We should still be able to only create one of those, but as its tied to the Configuration, which is mutable, need to think a bit more about that scenario.

References

Review Checklist