Repository navigation
MLE-32953: Do not resend a one-shot request after a 502, 503 or 504 - #2002
Open
prgs-rsingh wants to merge 1 commit into
Open
prgs-rsingh wants to merge 1 commit into
prgs-rsingh wants to merge 1 commit into
Conversation
The client sends a request again after a 502, 503 or 504. Content that can only be read once had been consumed by the attempt that failed, so the request was sent again without it. An Optic plan that writes documents from an InputStreamHandle could store empty documents this way, without an error. - sendRequestWithRetry and the retry loops of search() and match(QueryDefinition) now throw a ResourceNotResendableException when the body of the failed request is one-shot. This covers the callers that had no check of their own: Optic plans with bound content, values() with a raw query, match() with a document, and search() and match() with a raw query. - Content that can be read again is still sent again. - OneShotRequestRetryTest covers each of these with a mock server, for each retryable status, along with the cases that must not change: a caller with a check of its own, a request without a body, a request in a transaction, a status that is not retried, an OutputStreamHandle marked as resendable, a resendable request while the server stays unavailable, and the ping before the next one-shot request with digest authentication.
prgs-rsingh
requested review from
NiteshMehta,
adganta,
ashokrprogress,
hmadala001,
rjrudin and
vishwach
as code owners
December 3, 2026 09:06
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the change preventing retries of consumed one-shot request bodies.
No open issues 🎉
What changed in this PR
Prevents the Java client from resending consumed, one-shot request bodies after HTTP 502, 503, or 504 responses, building on #1995’s reliable isOneShot() detection.
Changes:
- Adds a shared resendability check to the common retry path and separate search/match loops.
- Preserves caller-specific checks and retries for resendable content.
- Adds regression tests covering streaming handles, retry statuses, transactions, and digest authentication.
| File | Description |
|---|---|
| marklogic-client-api/src/test/java/com/marklogic/client/impl/OneShotRequestRetryTest.java | Tests one-shot rejection and existing retry behavior. |
| marklogic-client-api/src/main/java/com/marklogic/client/impl/OkHttpServices.java | Rejects retries when the sent request body is one-shot. |
Review effort: Balanced
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.
Problem
The client sends a request again after a 502, 503 or 504. Several calls did not check whether the content of the request could be read again:
bindParam(…, DocumentWriteSet);values(),search()andmatch()with a raw query;match()with a document.Content that can only be read once, such as an
InputStreamHandle, had been consumed by the attempt that failed, so the request was sent again without it. An Opticwrite()ofInputStreamHandledocuments could store empty documents this way, with no error. AReaderfailed withStream closedinstead.This predates #1995 and was raised in its review. It is a follow-up to #1995, which made
isOneShot()reliable for every request body and is what makes a single check possible.Changes
OkHttpServices.throwIfRequestCannotBeSentAgainthrows aResourceNotResendableExceptionwhen the body of a request that was answered with 502, 503 or 504 is one-shot. It is called fromsendRequestWithRetry, which covers the Optic,values()andmatch(document)calls, and from the retry loops ofsearch()andmatch(QueryDefinition), which have loops of their own.sendRequestWithRetrythe check runs after a caller's own check, so callers that already had one report the same message as before.Behavior changes
ResourceNotResendableExceptionin the calls listed above, as a document write already did. These calls used to send the request again without its content.OutputStreamHandlecounts as one-shot unlesssetResendable(true)is called on it. An application that uses one in these calls with a sender that can write its content repeatedly has to call that to keep the retry.Tests
OneShotRequestRetryTestuses a mock server that answers the first request with a retryable status. 25 tests:Reader, for anOutputStreamHandle, and for one one-shot document among resendable ones.With the check disabled, the 13 tests that expect a one-shot request not to be sent again fail.
Run locally together with
StreamingPartRequestTest,StreamingOutputImplTest,ChunkedGzipConnectionCloseInterceptorTestandOkHttpUtilConnectionPoolTest: 48 tests pass. The tests that need MarkLogic were not run locally.