wombatu-kun opened a new pull request, #16578: URL: https://github.com/apache/iceberg/pull/16578
Closes #15030. ## Summary The Iceberg REST catalog client occasionally fails with an unrecoverable `RESTException: Failed to convert HTTP response body to string` caused by `MalformedChunkCodingException` while reading a chunked/gzip response body. The failure is transient (restarting the affected process — e.g. a Kafka Connect sink — recovers), so it should be retried rather than surfaced as fatal. The client already retries idempotent requests on transient `IOException`s via `ExponentialHttpRequestRetryStrategy`, and `MalformedChunkCodingException` is not in its non-retriable set. The gap is structural: Apache HttpClient5's retry runs in the `HttpRequestRetryExec` chain element, which only covers connecting and reading the response headers. The response body is read later, in the response handler (outside the exec chain), so a body-read failure bypasses the retry entirely. ## What changed Added an exec-chain interceptor, registered immediately inside `HttpRequestRetryExec`, that fully buffers the response entity (`BufferedHttpEntity`). Because the body is now read inside the retry-aware part of the chain, a transient body-read `IOException` is surfaced to the existing retry strategy and retried like any other transient failure — same idempotency check, same non-retriable classification, same exponential backoff, and a fresh connection per attempt. The entity is wrapped transparently (content type and encoding preserved), so the body is still parsed exactly once by the response handler and no other code paths change. Non-idempotent requests (e.g. commits) are not retried on a body-read failure: the retry strategy only retries idempotent methods on transient `IOException`s. This change makes idempotent body-read failures retryable while leaving non-idempotent requests unaffected — matching how the strategy already treats connection- and header-level `IOException`s. ## Tests Added a test in `TestHTTPClient` that uses a small raw-socket server (MockServer cannot emit a malformed chunked response) returning a malformed chunked body on the first connection and a valid response on the second, asserting that an idempotent GET transparently retries on a fresh connection and succeeds. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
