Skip to content

fix(client): set default timeouts and bound the oauth token request - #722

Merged
rodrigojara-cko merged 2 commits into
masterfrom
fix/INT-1852-default-http-timeouts
Dec 4, 2026
Merged

rodrigojara-cko merged 2 commits into
masterfrom
fix/INT-1852-default-http-timeouts

Conversation

@rodrigojara-cko

@rodrigojara-cko rodrigojara-cko commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The HTTP client builder the SDK creates had no request configuration, so a request to an API that accepted the connection and never answered kept the caller waiting with no limit, on the API requests and on the OAuth token requests. That builder now sets a 10 second connect timeout, a 60 second connection request timeout and a 60 second socket timeout, and an OAuth token request is bounded also when the application's own HttpClientBuilder sets no timeout.

Changes

  • src/main/java/com/checkout/AbstractCheckoutSdkBuilder.java: the builder the SDK creates gets a RequestConfig with connect 10 s, connection request 60 s and socket 60 s; httpClientBuilder(...) is unchanged and its javadoc says the defaults do not apply to a builder passed to it. The class, its public and protected methods and build() now have javadoc.
  • src/main/java/com/checkout/OAuthSdkCredentials.java: the token request still uses the client configuration unchanged; when that configuration does not have a positive connect, connection request and socket timeout, the request is aborted after 60 seconds in total (a DNS lookup still running is not interrupted).
  • README.md: a "Default timeouts" section with the values, the exceptions and how to set other timeouts; the custom HttpClientBuilder examples set timeouts.
  • src/test/java/com/checkout/DefaultHttpClientTimeoutsTest.java (new).

Most of the added lines are tests (469 of 761); 127 of the 156 lines added to AbstractCheckoutSdkBuilder are the javadoc the class needs once it is touched.

Design notes: the API requests use a builder passed to httpClientBuilder(...) as given; the SDK does not change a client the application configured, and HttpClientBuilder has no getter to merge with it. The token request must not wait with no limit whatever the builder: token requests are serialized (one at a time per credentials, the first one inside build()), so one that never ends blocks every OAuth request of the application, while a hung API request blocks only its caller. So a client that does not bound every wait gets a deadline for the whole token request instead of changed timeouts: every timeout the application set, including a socket timeout set through a SocketConfig, which the built client does not expose, still applies. Apache HttpClient 4 has no total request timeout, so the deadline aborts the request from one shared daemon thread. When the builder leaves any of the three unset, the deadline also caps a timeout it sets above 60 seconds; the README says to set all three to keep longer values. With the builder the SDK creates, or one that sets all three, no deadline is scheduled: each wait of the HTTP client is bounded (the DNS lookup is not one of them and keeps the system resolver's limits), but a server that keeps sending data slowly can hold a token request longer than 60 seconds. The default socket timeout is a limit between packets, as the Python SDK's 60 second read timeout between bytes; only the token deadline is a total. A deadline that fires while the token response body is being read surfaces as an invalid token response, still a CheckoutAuthorizationException, without the cause, like any token response body that cannot be read. The Go SDK bounds the token request at 5 seconds when its client sets no Timeout; here the deadline is 60 seconds, the same as the socket timeout, because it only applies to the merchant's own client (the builder the SDK creates gets none) and is a backstop for that transport, not a tighter limit than the merchant's own settings would give. No timeout setters are added to the SDK builder, since they could not be combined with httpClientBuilder(...). Package-private overloads (defaultHttpClientBuilder(RequestConfig), OAuthSdkCredentials constructors with the deadline and with the scheduler that runs it) let the tests run the same code with a short bound; the public API is unchanged. The deadline thread has no context class loader and ends 5 seconds after the last pending deadline; while it runs it keeps the SDK classes loaded, so a redeployed application releases them a few seconds after its last token request. The connection request timeout is 60 seconds, the same as the socket timeout: the default pool has 2 connections per host, so a shorter wait would fail a request queued behind two slow ones before it is sent.

API Reference

None. No request or response changes.

Breaking changes

None in the public signatures. Behaviour changes, released as a minor version (a correction of requests that could wait with no limit):

  • A request through the builder the SDK creates that gets no answer now fails after the bound (10 s to connect, 60 s for a pooled connection, 60 s without data) with a CheckoutApiException (status 400, with the default transport configuration), or a CheckoutAuthorizationException for a token request, instead of waiting with no limit. This cannot be kept as before: the bound is the fix. Migration: to use other timeouts, pass a builder with setDefaultRequestConfig through httpClientBuilder(...).
  • With OAuth and a builder passed to httpClientBuilder(...) that does not set a positive connect, connection request and socket timeout, a token request that has not finished after 60 seconds is aborted with a CheckoutAuthorizationException. The builder's own timeouts are unchanged. This cannot be kept as before: token requests are serialized, so one with no limit blocks every OAuth request of the application. Migration: none needed; to bound the token requests differently, set all three timeouts with setDefaultRequestConfig.

Tests

  • Existing tests pass
  • Serialization tests cover every new or changed property: not applicable, no request or response type changed
  • README updated if documented usage changed

DefaultHttpClientTimeoutsTest checks the defaults on the builder the SDK creates (static keys, OAuth and the previous platform), that they are kept after the SDK is built, a custom builder used unchanged and its request configuration kept, the configuration of the token and API requests (default timeouts, redirects off on the token request; a custom builder's configuration unchanged; a client without configuration falls back to RequestConfig.DEFAULT with redirects off), and, against a local server that accepts the connection and never answers: an API request (CheckoutApiException); the token request with the builder the SDK creates (ends on its own socket timeout); aborted at the deadline, with the abort as the cause, with a custom builder without timeouts, with timeouts of 0, with one timeout unset and another longer than the deadline, and with exactly one of the connect, connection request or socket timeouts unset and the other two longer (one case each); no deadline when the client bounds every wait (ends on its socket timeout, not on an abort); and a custom socket timeout set through RequestConfig or SocketConfig kept; each token case fails with CheckoutAuthorizationException within the bound. It also checks that the deadline is cancelled and removed from its scheduler when the token request ends, and that the deadline scheduler lets its thread end when idle, removes cancelled deadlines and creates a daemon thread without a context class loader.

Related

None.

@rodrigojara-cko
rodrigojara-cko requested a review from a team December 1, 2026 11:31
@agent-wall-e

agent-wall-e Bot commented Dec 1, 2026

Copy link
Copy Markdown

🔴 Risk Classification: MAJOR

Approval route: AI Review + Human Approval Required
Rollback controls: Change-freeze window + documented rollback plan

Classification reasons

  • security_sensitive_path:src/main/java/com/checkout/OAuthSdkCredentials.java

Operational gates

  • ✅ jira_ticket (INT-1852)
  • ✅ independent_review

Files analysed: 4


wall-e 2026.06.19-02 · policy 6b4ce2b3b45a…

@agent-wall-e

agent-wall-e Bot commented Dec 1, 2026

Copy link
Copy Markdown
🔬 Debug — why this classification?

Each reason code emitted by the classifier, its source clause in the AI in SDLC Control Framework, and what it means.

Reason code Kind Clause Meaning
security_sensitive_path — src/main/java/com/checkout/OAuthSdkCredentials.java classifying §2.1 M4/M5 Path matched a sensitive pattern (auth, secrets, crypto, PCI, migrations, network IaC).

Kinds:

  • classifying — this rule contributed to the chosen tier.
  • informational — context only; did not by itself decide the tier.

See issue #3 for the proposal to formalise this map as Appendix A of the standards doc.

wall-e 2026.06.19-02 · debug

@agent-wall-e

agent-wall-e Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

🔵 Advisory review: Sound, but needs your judgement

This PR needs a human approval. The code itself reads as correct; whether it should land depends on context I don't have.

This PR adds default timeouts (10s connect, 60s connection-request, 60s socket) to the SDK's built-in HttpClientBuilder and a 60s deadline abort for OAuth token requests when the caller-supplied builder lacks explicit timeouts. The implementation looks technically sound, but several design decisions with real operational consequences deserve explicit team sign-off.

For you to decide

  • The 60-second token-request deadline only fires when the caller's builder omits any of the three timeout types; if exactly one is missing (e.g. no connection-request timeout but socket timeout is set to 120 s) the deadline caps the whole request at 60 s even though the caller expressed a preference for a longer wait — the README documents this but it is a surprising footgun worth confirming the team accepts.
  • The shared DEADLINES ScheduledThreadPoolExecutor is a JVM-wide static; its keep-alive of 5 seconds after the last pending deadline is undocumented in terms of class-loader retention impact in servlet containers or OSGi — the PR description mentions this but the reviewer should decide whether it is acceptable for the target deployment environments.
  • The boundsEveryWait check reads the RequestConfig obtained from withoutRedirects(client), which merges client defaults with any request-level config; if withoutRedirects builds a config that inherits the SDK defaults (e.g. for the default builder path), boundsEveryWait would return true and skip the deadline — worth confirming the test coverage for this specific interaction path actually exercises the withoutRedirects output rather than a raw RequestConfig.
  • The OAuth deadline is cancelled with deadline.cancel(false) (non-interrupting), meaning if the scheduler fires the abort just before cancel is called in finally, the HttpPost is aborted but the response is already being read — the PR description acknowledges this surfaces as an INVALID_TOKEN_RESPONSE; teams relying on the exception cause chain for monitoring/alerting should be aware.
  • The diff is truncated so the full withoutRedirects implementation, the defaultHttpClientBuilder(RequestConfig) overload used by tests, and the remainder of the test file are not visible — a reviewer should verify those before approving.
  • The RequestConfig.DEFAULT connect/connection-request timeouts are -1 (infinite) in Apache HttpClient 4; the test shouldUseACustomHttpClientBuilderWithoutTheDefaultTimeouts asserts the custom builder keeps those infinite defaults, which correctly documents the 'no defaults applied' behaviour but means a caller who passes a bare HttpClientBuilder.create() gets unbounded waits — the README documents this, but the team should confirm this trade-off is intentional.

⚠️ The diff was too large to read in full, so this review covers only part of the change.


This is not an approval. wall-e cannot auto-approve this PR — it is an opinion to help whoever does. Advisory review · us.anthropic.claude-sonnet-4-6 · wall-e 2026.06.19-02

@rodrigojara-cko
rodrigojara-cko force-pushed the fix/INT-1852-default-http-timeouts branch from ec24067 to 63a310e Compare December 1, 2026 12:34
@agent-wall-e

agent-wall-e Bot commented Dec 1, 2026

Copy link
Copy Markdown

🔴 Risk Classification: MAJOR

Approval route: AI Review + Human Approval Required
Rollback controls: Change-freeze window + documented rollback plan

Classification reasons

  • security_sensitive_path:src/main/java/com/checkout/OAuthSdkCredentials.java

Operational gates

  • ✅ jira_ticket (INT-1852)
  • ✅ independent_review

Files analysed: 4


wall-e 2026.06.19-02 · policy 6b4ce2b3b45a…

@agent-wall-e

agent-wall-e Bot commented Dec 1, 2026

Copy link
Copy Markdown
🔬 Debug — why this classification?

Each reason code emitted by the classifier, its source clause in the AI in SDLC Control Framework, and what it means.

Reason code Kind Clause Meaning
security_sensitive_path — src/main/java/com/checkout/OAuthSdkCredentials.java classifying §2.1 M4/M5 Path matched a sensitive pattern (auth, secrets, crypto, PCI, migrations, network IaC).

Kinds:

  • classifying — this rule contributed to the chosen tier.
  • informational — context only; did not by itself decide the tier.

See issue #3 for the proposal to formalise this map as Appendix A of the standards doc.

wall-e 2026.06.19-02 · debug

@rodrigojara-cko
rodrigojara-cko force-pushed the fix/INT-1852-default-http-timeouts branch from 63a310e to 4524b0e Compare December 1, 2026 13:25
@agent-wall-e

agent-wall-e Bot commented Dec 1, 2026

Copy link
Copy Markdown

🔴 Risk Classification: MAJOR

Approval route: AI Review + Human Approval Required
Rollback controls: Change-freeze window + documented rollback plan

Classification reasons

  • security_sensitive_path:src/main/java/com/checkout/OAuthSdkCredentials.java

Operational gates

  • ✅ jira_ticket (INT-1852)
  • ✅ independent_review

Files analysed: 4


wall-e 2026.06.19-02 · policy 6b4ce2b3b45a…

@agent-wall-e

agent-wall-e Bot commented Dec 1, 2026

Copy link
Copy Markdown
🔬 Debug — why this classification?

Each reason code emitted by the classifier, its source clause in the AI in SDLC Control Framework, and what it means.

Reason code Kind Clause Meaning
security_sensitive_path — src/main/java/com/checkout/OAuthSdkCredentials.java classifying §2.1 M4/M5 Path matched a sensitive pattern (auth, secrets, crypto, PCI, migrations, network IaC).

Kinds:

  • classifying — this rule contributed to the chosen tier.
  • informational — context only; did not by itself decide the tier.

See issue #3 for the proposal to formalise this map as Appendix A of the standards doc.

wall-e 2026.06.19-02 · debug

@rodrigojara-cko
rodrigojara-cko force-pushed the fix/INT-1852-default-http-timeouts branch from 4524b0e to 01c9c80 Compare December 1, 2026 16:47
@rodrigojara-cko rodrigojara-cko changed the title fix(client): set default timeouts on the http client the sdk creates fix(client): set default timeouts and bound the oauth token request Dec 1, 2026
@agent-wall-e

agent-wall-e Bot commented Dec 1, 2026

Copy link
Copy Markdown

🔴 Risk Classification: MAJOR

Approval route: AI Review + Human Approval Required
Rollback controls: Change-freeze window + documented rollback plan

Classification reasons

  • security_sensitive_path:src/main/java/com/checkout/OAuthSdkCredentials.java

Operational gates

  • ✅ jira_ticket (INT-1852)
  • ✅ independent_review

Files analysed: 4


wall-e 2026.06.19-02 · policy 6b4ce2b3b45a…

@agent-wall-e

agent-wall-e Bot commented Dec 1, 2026

Copy link
Copy Markdown
🔬 Debug — why this classification?

Each reason code emitted by the classifier, its source clause in the AI in SDLC Control Framework, and what it means.

Reason code Kind Clause Meaning
security_sensitive_path — src/main/java/com/checkout/OAuthSdkCredentials.java classifying §2.1 M4/M5 Path matched a sensitive pattern (auth, secrets, crypto, PCI, migrations, network IaC).

Kinds:

  • classifying — this rule contributed to the chosen tier.
  • informational — context only; did not by itself decide the tier.

See issue #3 for the proposal to formalise this map as Appendix A of the standards doc.

wall-e 2026.06.19-02 · debug

@rodrigojara-cko
rodrigojara-cko force-pushed the fix/INT-1852-default-http-timeouts branch from 01c9c80 to d3aef24 Compare December 3, 2026 16:02
@agent-wall-e

agent-wall-e Bot commented Dec 3, 2026

Copy link
Copy Markdown

🔴 Risk Classification: MAJOR

Approval route: AI Review + Human Approval Required
Rollback controls: Change-freeze window + documented rollback plan

Classification reasons

  • security_sensitive_path:src/main/java/com/checkout/OAuthSdkCredentials.java

Operational gates

  • ✅ jira_ticket (INT-1852)
  • ✅ independent_review

Files analysed: 4


wall-e 2026.06.19-02 · policy 6b4ce2b3b45a…

@agent-wall-e

agent-wall-e Bot commented Dec 3, 2026

Copy link
Copy Markdown
🔬 Debug — why this classification?

Each reason code emitted by the classifier, its source clause in the AI in SDLC Control Framework, and what it means.

Reason code Kind Clause Meaning
security_sensitive_path — src/main/java/com/checkout/OAuthSdkCredentials.java classifying §2.1 M4/M5 Path matched a sensitive pattern (auth, secrets, crypto, PCI, migrations, network IaC).

Kinds:

  • classifying — this rule contributed to the chosen tier.
  • informational — context only; did not by itself decide the tier.

See issue #3 for the proposal to formalise this map as Appendix A of the standards doc.

wall-e 2026.06.19-02 · debug

@rodrigojara-cko
rodrigojara-cko force-pushed the fix/INT-1852-default-http-timeouts branch from d3aef24 to 4806921 Compare December 4, 2026 12:49
@agent-wall-e

agent-wall-e Bot commented Dec 4, 2026

Copy link
Copy Markdown

🔴 Risk Classification: MAJOR

Approval route: AI Review + Human Approval Required
Rollback controls: Change-freeze window + documented rollback plan

Classification reasons

  • security_sensitive_path:src/main/java/com/checkout/OAuthSdkCredentials.java

Operational gates

  • ✅ jira_ticket (INT-1852)
  • ✅ independent_review

Files analysed: 4


wall-e 2026.06.19-02 · policy 6b4ce2b3b45a…

@agent-wall-e

agent-wall-e Bot commented Dec 4, 2026

Copy link
Copy Markdown
🔬 Debug — why this classification?

Each reason code emitted by the classifier, its source clause in the AI in SDLC Control Framework, and what it means.

Reason code Kind Clause Meaning
security_sensitive_path — src/main/java/com/checkout/OAuthSdkCredentials.java classifying §2.1 M4/M5 Path matched a sensitive pattern (auth, secrets, crypto, PCI, migrations, network IaC).

Kinds:

  • classifying — this rule contributed to the chosen tier.
  • informational — context only; did not by itself decide the tier.

See issue #3 for the proposal to formalise this map as Appendix A of the standards doc.

wall-e 2026.06.19-02 · debug

The HTTP client builder created by the SDK had no request configuration,
so a server that accepted the connection and never answered kept the
caller waiting with no limit, on the API requests and on the OAuth token
requests.

Behaviour change: the builder the SDK creates now sets a connect timeout
of 10 seconds, a connection request timeout of 60 seconds and a socket
timeout of 60 seconds, so a request that gets no response fails instead
of waiting. The connection request timeout matches the socket timeout
because the default pool has 2 connections per host: a shorter wait would
fail a request queued behind two slow ones before it is sent. The OAuth
token requests use the same builder, so they get the same bounds. A
builder passed through httpClientBuilder(...) is used unchanged; set
timeouts on it with setDefaultRequestConfig.
The token request copies the request configuration of the client, so with
an HttpClientBuilder passed to httpClientBuilder(...) that sets no timeout
it could wait with no limit. Token requests are serialized (one at a time
per credentials, the first one inside build()), so a token request that
never ends blocks every OAuth request of the application.

When that configuration does not have a positive connect, connection
request and socket timeout, the token request is now aborted after 60
seconds in total; a DNS lookup still running is not interrupted. The
client configuration is used unchanged, so every timeout the merchant set,
including a socket timeout set through a SocketConfig, still applies and
ends the request first when it is shorter. The API requests still use the
merchant builder as given.
@rodrigojara-cko
rodrigojara-cko force-pushed the fix/INT-1852-default-http-timeouts branch from 4806921 to 3c1ce5e Compare December 4, 2026 13:56
@agent-wall-e

agent-wall-e Bot commented Dec 4, 2026

Copy link
Copy Markdown

🔴 Risk Classification: MAJOR

Approval route: AI Review + Human Approval Required
Rollback controls: Change-freeze window + documented rollback plan

Classification reasons

  • security_sensitive_path:src/main/java/com/checkout/OAuthSdkCredentials.java

Operational gates

  • ✅ jira_ticket (INT-1852)
  • ✅ independent_review

Files analysed: 4


wall-e 2026.06.19-02 · policy 6b4ce2b3b45a…

@agent-wall-e

agent-wall-e Bot commented Dec 4, 2026

Copy link
Copy Markdown
🔬 Debug — why this classification?

Each reason code emitted by the classifier, its source clause in the AI in SDLC Control Framework, and what it means.

Reason code Kind Clause Meaning
security_sensitive_path — src/main/java/com/checkout/OAuthSdkCredentials.java classifying §2.1 M4/M5 Path matched a sensitive pattern (auth, secrets, crypto, PCI, migrations, network IaC).

Kinds:

  • classifying — this rule contributed to the chosen tier.
  • informational — context only; did not by itself decide the tier.

See issue #3 for the proposal to formalise this map as Appendix A of the standards doc.

wall-e 2026.06.19-02 · debug

@sonarqubecloud

sonarqubecloud Bot commented Dec 4, 2026

Copy link
Copy Markdown

@rodrigojara-cko
rodrigojara-cko merged commit bec6683 into master Dec 4, 2026
6 checks passed
@rodrigojara-cko
rodrigojara-cko deleted the fix/INT-1852-default-http-timeouts branch December 4, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants