Radiancebobo opened a new pull request, #25931: URL: https://github.com/apache/pulsar/pull/25931
### Motivation `RetryUtil.retryAsynchronously` accepts a `Supplier<CompletableFuture<T>>` and retries when the returned future completes exceptionally. However, if the supplier throws before returning a future, the exception escapes from the executor task before `whenComplete` is registered. In that case, the retry loop does not schedule another attempt and the caller-provided callback is never completed. A transient synchronous failure while building the async operation can therefore become a permanently pending callback. ### Modifications - Wrap the supplier invocation in `RetryUtil` so synchronous exceptions are converted into an exceptionally completed future. - Treat a `null` future from the supplier as an explicit failure instead of allowing an uncontrolled `NullPointerException`. - Add a regression test that verifies a synchronous failure on the first attempt is retried and the callback completes successfully on the second attempt. ### Verifying this change - [x] Make sure that the change passes the CI checks. This change added tests and can be verified as follows: - Added `RetryUtilTest.testSyncFailureIsRetried` to cover supplier exceptions thrown before a future is returned. - Verified the new regression test: ```bash ./gradlew :pulsar-broker:test --tests org.apache.pulsar.client.impl.RetryUtilTest.testSyncFailureIsRetried -PtestGroups=utils -PtestRetryCount=0 ``` - Verified the adjacent test class: ```bash ./gradlew :pulsar-broker:test --tests org.apache.pulsar.client.impl.RetryUtilTest -PtestGroups=utils -PtestRetryCount=0 ``` ### Does this pull request potentially affect one of the following parts: *If the box was checked, please highlight the changes* - [ ] Dependencies (add or upgrade a dependency) - [ ] The public API - [ ] The schema - [ ] The default values of configurations - [ ] The threading model - [ ] The binary protocol - [ ] The REST endpoints - [ ] The admin CLI options - [ ] The metrics - [ ] Anything that affects deployment -- 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]
