Skip to content

Commit

Permalink
[CELEBORN-1430] TransportClientFactory should check whether handler i…
Browse files Browse the repository at this point in the history
…s null when creating client

### What changes were proposed in this pull request?

`TransportClientFactory` checks whether `handler` is null when creating client.

### Why are the changes needed?

There is a case that `cachedClient.isActive()` may return true and may return false when checked for the second time when another thread is closing the channel, which causes that the `handler` may be null. Therefore, `TransportClientFactory` should check whether handler is null when creating client.

Backport apache/spark#46506.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

GA.

Closes #2517 from SteNicholas/CELEBORN-1430.

Authored-by: SteNicholas <programgeek@163.com>
Signed-off-by: mingji <fengmingxiao.fmx@alibaba-inc.com>
  • Loading branch information
SteNicholas authored and FMX committed May 16, 2024
1 parent 8b7a2da commit b864794
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ public TransportClient createClient(
// this code was able to update things.
TransportChannelHandler handler =
cachedClient.getChannel().pipeline().get(TransportChannelHandler.class);
synchronized (handler) {
handler.getResponseHandler().updateTimeOfLastRequest();
if (handler != null) {
synchronized (handler) {
handler.getResponseHandler().updateTimeOfLastRequest();
}
}

if (cachedClient.isActive()) {
Expand Down

0 comments on commit b864794

Please sign in to comment.