Search before asking
Apache ShenYu Component
shenyu-sync-data-http
What happened
HttpSyncDataService.HttpLongPollingTask.run() retries failed long-poll requests with a for (time = 1; time <= retryTimes; time++) loop, but it does not leave that retry loop after a successful doLongPolling(server) call.
Current code in shenyu-sync-data-center/shenyu-sync-data-http/src/main/java/org/apache/shenyu/sync/data/http/HttpSyncDataService.java:
while (RUNNING.get()) {
int retryTimes = 10;
for (int time = 1; time <= retryTimes; time++) {
try {
//do long polling.
doLongPolling(server);
} catch (Exception e) {
if (time < retryTimes) {
ThreadUtils.sleep(TimeUnit.SECONDS, 5);
continue;
}
ThreadUtils.sleep(TimeUnit.MINUTES, 5);
}
}
}
When doLongPolling(server) succeeds, execution continues to the next for iteration. A single outer loop can therefore perform 10 successful long-poll requests back-to-back instead of one successful poll followed by the next outer loop cycle.
This can create unnecessary long-poll traffic and makes the retry counter behave as a fixed repeat count even when no retry is needed.
What you expected to happen
After a successful doLongPolling(server) call, the retry loop should stop for the current outer iteration, for example by break-ing out of the for loop. The retry loop should only continue after failures.
How to reproduce
- Configure ShenYu bootstrap to use HTTP sync.
- Start admin and bootstrap while the long-poll endpoint is healthy.
- Observe that
HttpLongPollingTask.run() can execute doLongPolling(server) up to 10 times per outer while (RUNNING.get()) loop because success does not break the retry loop.
Debug logs
No response
Environment
Current master branch.
Are you willing to submit PR?
Search before asking
Apache ShenYu Component
shenyu-sync-data-http
What happened
HttpSyncDataService.HttpLongPollingTask.run()retries failed long-poll requests with afor (time = 1; time <= retryTimes; time++)loop, but it does not leave that retry loop after a successfuldoLongPolling(server)call.Current code in
shenyu-sync-data-center/shenyu-sync-data-http/src/main/java/org/apache/shenyu/sync/data/http/HttpSyncDataService.java:When
doLongPolling(server)succeeds, execution continues to the nextforiteration. A single outer loop can therefore perform 10 successful long-poll requests back-to-back instead of one successful poll followed by the next outer loop cycle.This can create unnecessary long-poll traffic and makes the retry counter behave as a fixed repeat count even when no retry is needed.
What you expected to happen
After a successful
doLongPolling(server)call, the retry loop should stop for the current outer iteration, for example bybreak-ing out of theforloop. The retry loop should only continue after failures.How to reproduce
HttpLongPollingTask.run()can executedoLongPolling(server)up to 10 times per outerwhile (RUNNING.get())loop because success does not break the retry loop.Debug logs
No response
Environment
Current master branch.
Are you willing to submit PR?