Skip to content

Commit 36cf17d

Browse files
authored
[netty] Wrap IOException to NetworkException to retry send to avoid making job fail directly (#506)
1 parent 56a457e commit 36cf17d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

fluss-rpc/src/main/java/com/alibaba/fluss/rpc/netty/client/ServerConnection.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,15 @@ private CompletableFuture<ApiMessage> doSend(
327327
if (!future.isSuccess()) {
328328
connectionMetricGroup.updateMetricsAfterGetResponse(
329329
apiKey, inflight.requestStartTime, 0);
330-
inflight.responseFuture.completeExceptionally(
331-
future.cause());
330+
Throwable cause = future.cause();
331+
if (cause instanceof IOException) {
332+
// when server close the channel, the cause will be
333+
// IOException, if the cause is IOException, we wrap
334+
// it as retryable NetworkException to retry to
335+
// connect
336+
cause = new NetworkException(cause);
337+
}
338+
inflight.responseFuture.completeExceptionally(cause);
332339
inflightRequests.remove(inflight.requestId);
333340
}
334341
});

0 commit comments

Comments
 (0)