[CHA-2956] connection pooling: stream-sdk-java#64
Merged
Conversation
Strip Notion spec links and section refs from CHANGELOG, javadoc, and comments. Behavior unchanged; CHA-2956 references kept.
…elongs in chat/ templates
…verrides The env/properties constructor paths parsed STREAM_API_TIMEOUT / io.getstream.timeout and STREAM_API_CONNECTION_MAX_AGE / io.getstream.connection.maxAge into private fields that defaultHttpClientBuilder() no longer reads after the CHA-2956 rewrite to StreamClientOptions. Existing deployments relying on those env vars silently lost their override and jumped to the 30s/55s defaults. Fold the parsed values into the default StreamClientOptions when (and only when) the env var / system property is explicitly present, so the request-timeout and idle-timeout knobs honor them again. An explicitly passed StreamClientOptions (3-arg ctor) still wins since that path never reads env vars; an unset var leaves the options defaults intact.
maxConnsPerHost was wired only to OkHttp's ConnectionPool, which controls the idle-pool SIZE, not a per-host concurrency ceiling. The real per-host limit is Dispatcher.maxRequestsPerHost (OkHttp default 5). Construct a Dispatcher and set maxRequestsPerHost to the configured maxConnsPerHost so the knob actually caps in-flight requests per host; keep the existing ConnectionPool sizing too. The OkHttp default (5) equals our default, so default behavior is unchanged. Also apply idleTimeout with millisecond precision (toMillis + MILLISECONDS) for parity with the other Duration knobs instead of truncating to whole seconds, and correct the user-http-client INFO log to say "4 knobs" (setHttpClient is the escape hatch itself, not a tunable).
slavabobik
approved these changes
May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements explicit HTTP connection pooling for stream-sdk-java (CHA-2956).
StreamClientOptionsPOJO with fluent setters for the 5 canonical knobs:setMaxConnsPerHost,setIdleTimeout,setConnectTimeout,setRequestTimeout,setHttpClient.StreamSDKClient(apiKey, secret, StreamClientOptions)constructor overload.java.util.logging.Logger. No new dependency.RequestTimeoutoverride:request.callTimeout(Duration.ofSeconds(5)).execute().setHttpClient(OkHttpClient)is the escape hatch; bypasses all 4 knobs.StreamSDKClient(apiKey, secret, OkHttpClient)escape hatch preserved.Version bump 7.2.0 to 7.3.0.
Behavior change
Default per-call
RequestTimeoutmoves from 10s to 30s. Aligns with the cross-SDK contract. Existing callers needing the old 10s ceiling should passnew StreamClientOptions().setRequestTimeout(Duration.ofSeconds(10)). CHANGELOG calls this out under "Changed."Test plan
StreamClientOptionsdefaults + fluent setter chainingStreamHTTPClientuses options-derivedConnectionPool+connectTimeout+callTimeoutStreamSDKClient(apiKey, secret, options)constructor flows options throughsetHttpClient(OkHttpClient)escape hatch via options: 4 knobs bypassed, user pool/timeouts preservedStreamSDKClient(apiKey, secret, OkHttpClient)escape hatch still worksrequest.callTimeout(Duration)pre-empts client-widecallTimeout(MockWebServer)user_http_client=false)setHttpClient(assertsuser_http_client=true)./gradlew spotlessApplyclean./gradlew test --no-daemon --tests 'io.getstream.StreamHTTPClientTest' --tests 'io.getstream.StreamRequestCallTimeoutTest'17/17 PASS./gradlew build --no-daemon -x testBUILD SUCCESSFULNote on full integration suite
./gradlew test --no-daemon(full suite) fails onChatChannelIntegrationTest.testHardDeleteChannelswithTask ... did not complete after 30 attempts. This is a pre-existing live-server timing flake; the same test fails identically onorigin/mainin the full-suite run. The 30s polling window inwaitForTaskis insufficient when the live backend's async hard-delete task processor is under load. Unrelated to this change. Verified by running the full suite onorigin/mainimmediately before this PR.Refs