PDGGK opened a new pull request, #37356:
URL: https://github.com/apache/beam/pull/37356
## What changes are being proposed in this pull request?
This PR addresses issue #37198 by making the `withBackOffSupplier()` method
public in RequestResponseIO, allowing users to configure bounded backoff to
prevent infinite retry loops.
## Problem
Users cannot configure bounded retries because the `withBackOffSupplier()`
method has package-private visibility. This leads to:
- Inability to set retry limits (e.g.,
`FluentBackoff.DEFAULT.withMaxRetries(3)`)
- Risk of infinite retry loops in production
- No way to control retry behavior for different failure scenarios
## Solution
Changed `withBackOffSupplier()` visibility from package-private to `public`:
```java
// Before:
RequestResponseIO<RequestT, ResponseT>
withBackOffSupplier(SerializableSupplier<BackOff> value)
// After:
public RequestResponseIO<RequestT, ResponseT> withBackOffSupplier(
SerializableSupplier<BackOff> value)
```
This allows users to configure bounded retries:
```java
RequestResponseIO.of(caller, coder)
.withBackOffSupplier(() ->
FluentBackoff.DEFAULT.withMaxRetries(3).backoff())
```
## Testing
Added comprehensive integration test
`givenBoundedBackoff_thenRetriesStopAfterLimit()` that:
- Uses a serializable `BoundedBackOff` class with zero delays (no real
sleeps)
- Verifies with `PAssert` that responses are empty and exactly 1 failure is
emitted
- Verifies with metrics that call count = maxRetries + 1 (initial call + 3
retries)
- Verifies with metrics that failure count = 1
**Test results:**
- ✅ `./gradlew :sdks:java:io:rrio:check` passes
- ✅ All existing tests continue to pass
- ✅ New test validates bounded retry behavior
## Impact
- **User benefit**: Users can now prevent infinite retry loops by
configuring bounded backoff
- **Backward compatibility**: No breaking changes; existing code continues
to work
- **Production readiness**: Enables safer retry configurations for
production workloads
Fixes #37198
Related to #37176
--
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]