Skip to content

feat: Expose ConnectionPool customization on FlagsmithConfig.Builder#208

Merged
emyller merged 1 commit intomainfrom
feat/issue-207-connection-pool-config
Apr 21, 2026
Merged

feat: Expose ConnectionPool customization on FlagsmithConfig.Builder#208
emyller merged 1 commit intomainfrom
feat/issue-207-connection-pool-config

Conversation

@adamvialpando
Copy link
Copy Markdown
Contributor

Summary

Adds connectionPool(ConnectionPool) to FlagsmithConfig.Builder so users can tune OkHttp's idle connection behavior (keepAlive duration and max idle connections). This is the API requested in #207 for users running behind intermediaries (AWS ALB, nginx) that close idle sockets sooner than OkHttp's default of 5 minutes.

Default behavior is unchanged: when connectionPool() is not called (or is called with null), OkHttp's default pool is used, so existing users see no difference.

Usage

FlagsmithConfig config = FlagsmithConfig.newBuilder()
    .connectionPool(new ConnectionPool(5, 30, TimeUnit.SECONDS))
    .build();

Tests

Two new tests in FlagsmithConfigTest:

  1. configTest_customConnectionPool_respectsKeepAliveAndMaxIdle reflects into ConnectionPool.delegate and asserts the user's maxIdleConnections and keepAliveDurationNs reach the live pool. Mutation tested: removing the constructor wiring fails this test.
  2. configTest_nullConnectionPool_isSafeAndUsesDefault passes null explicitly and asserts no NPE; a default OkHttp pool is still wired. Mutation tested: removing the null guard fails this test.

Both tests pass on OkHttp 5.x and OkHttp 4.x (via the test-okhttp4 profile).

Add connectionPool(ConnectionPool) to FlagsmithConfig.Builder so users
can tune how long OkHttp keeps idle connections alive and how many it
retains. This addresses stale connection reuse when running behind
intermediaries (AWS ALB, nginx) that close idle sockets sooner than
OkHttp's default of 5 minutes.

Passing null, or not calling the method, preserves OkHttp's defaults.
Existing users see no behavior change.

Closes #207
@adamvialpando adamvialpando requested a review from a team as a code owner April 21, 2026 18:45
@adamvialpando adamvialpando requested review from Zaimwa9 and emyller and removed request for a team April 21, 2026 18:45
Copy link
Copy Markdown
Contributor

@emyller emyller left a comment

Choose a reason for hiding this comment

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

Looks great!

@emyller emyller merged commit bf7290e into main Apr 21, 2026
13 checks passed
@emyller emyller deleted the feat/issue-207-connection-pool-config branch April 21, 2026 19:17
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.

2 participants