Skip to content

feat: allow reusing an existing OkHttpClient via DefaultHttpClient.Bu… - #936

Merged
tanya732 merged 5 commits into
masterfrom
feat/reuse-okhttpclient-in-defaulthttpclient
Sep 30, 2026
Merged

tanya732 merged 5 commits into
masterfrom
feat/reuse-okhttpclient-in-defaulthttpclient

Conversation

@tanya732

@tanya732 tanya732 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds DefaultHttpClient.Builder.withClient(OkHttpClient), letting integrators reuse an existing OkHttpClient as the base for the Authentication API HTTP client.

The behavior boundary is deliberate and documented:

  • The supplied client owns all transport configuration, timeouts, dispatcher, connection pool, cache, proxy, and its own interceptors are reused as-is via baseClient.newBuilder(). The builder's transport setters (withReadTimeout, withConnectTimeout, withMaxRequests, withMaxRequestsPerHost, withProxy) are ignored when a base client is supplied, so the caller's client is never silently overridden. Each of those setters now carries a @see #withClient note.
  • The SDK always layers its behavior on top telemetry, rate-limit handling, and logging interceptors are added to the caller's client and cannot be bypassed; they remain configurable via withTelemetry / telemetryEnabled / withMaxRetries / withLogging.
  • The default path (no base client) is unchanged, existing users get identical behavior, no breaking change.

The Management API already accepts a raw OkHttpClient, so no generated code is touched.

References

Testing

  • New DefaultHttpClientTest (added to .fernignore) covering: base-client transport reused / builder transport ignored, default path still applies builder transport, SDK interceptors layered without mutating the original, null base client throws.
  • AuthAPITest integration test asserting a base-client interceptor header and the Auth0 telemetry header both appear.
  • ./gradlew spotlessApply check passes.

Checklist

  • Backward compatible
  • Tests added
  • Docs updated (EXAMPLES.md)

@tanya732
tanya732 requested a review from a team as a code owner September 28, 2026 06:07

@rmad17 rmad17 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@tanya732
tanya732 merged commit 00a3513 into master Sep 30, 2026
7 checks passed
@tanya732
tanya732 deleted the feat/reuse-okhttpclient-in-defaulthttpclient branch September 30, 2026 15:16
@tanya732 tanya732 mentioned this pull request Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants