REQ-3828: fix error handling

This commit is contained in:
yanglin 2024-12-26 09:33:42 +08:00
parent da96e90056
commit 93323fb4e0

View File

@ -34,14 +34,7 @@ public class BatchController {
}
public void submit(Runnable task) {
submitCount++;
if (submitCount <= parallelismThreshold) {
info("using sync");
task.run();
return;
}
info(String.format("using async because of parallelismThreshold > %d", parallelismThreshold));
asyncTasks.runAsync(() -> {
Runnable runner = () -> {
Exception exception = error.get();
if (exception != null) {
warn("operation aborted because of other batch's error", exception);
@ -53,7 +46,15 @@ public class BatchController {
warn("operation failed", e);
error.compareAndSet(null, e);
}
});
};
submitCount++;
if (submitCount <= parallelismThreshold) {
info("using sync");
runner.run();
return;
}
info(String.format("using async because of parallelismThreshold > %d", parallelismThreshold));
asyncTasks.runAsync(runner);
}
public void awaitTermination(long timeout, TimeUnit unit) throws Exception {