rkhachatryan commented on a change in pull request #14528:
URL: https://github.com/apache/flink/pull/14528#discussion_r551399086
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/netty/PartitionRequestClientFactory.java
##########
@@ -69,36 +68,34 @@
NettyPartitionRequestClient createPartitionRequestClient(ConnectionID
connectionId)
throws IOException, InterruptedException {
while (true) {
- AtomicBoolean isTheFirstOne = new AtomicBoolean(false);
- CompletableFuture<NettyPartitionRequestClient> clientFuture =
- clients.computeIfAbsent(
- connectionId,
- unused -> {
- isTheFirstOne.set(true);
- return new CompletableFuture<>();
- });
- if (isTheFirstOne.get()) {
+ final CompletableFuture<NettyPartitionRequestClient>
newClientFuture =
+ new CompletableFuture<>();
+
+ final CompletableFuture<NettyPartitionRequestClient> clientFuture =
+ clients.putIfAbsent(connectionId, newClientFuture);
+
+ final NettyPartitionRequestClient client;
+
+ if (clientFuture == null) {
try {
- clientFuture.complete(connectWithRetries(connectionId));
- } catch (InterruptedException e) {
- clientFuture.complete(null); // let others waiting know
that they should retry
+ client = connectWithRetries(connectionId);
+ } catch (RemoteTransportException | InterruptedException e) {
Review comment:
I think you're right. Though other clients (threads) waiting for this
future do `rethrowIOException`.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]