From 87d889265efa47e194f4d80d32d2abb08db285d0 Mon Sep 17 00:00:00 2001 From: Duong Nguyen Date: Wed, 7 Jun 2023 17:24:57 -0700 Subject: [PATCH 1/3] HDDS-8780. Leak of ManagedChannel in HASecurityUtils --- .../hadoop/hdds/scm/ha/HASecurityUtils.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/HASecurityUtils.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/HASecurityUtils.java index c55478647a14..59322595cf89 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/HASecurityUtils.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/HASecurityUtils.java @@ -351,16 +351,11 @@ public static SCMRatisResponse submitScmCertsToRatis(RaftGroup raftGroup, .setRetryPolicy( RetryPolicies.retryUpToMaximumCountWithFixedSleep(120, TimeDuration.valueOf(500, TimeUnit.MILLISECONDS))); - RaftClient raftClient = builder.build(); - - CompletableFuture future = - raftClient.async().send(message); - - RaftClientReply raftClientReply = future.get(); - - return SCMRatisResponse.decode(raftClientReply); - + CompletableFuture future; + try (RaftClient raftClient = builder.build()) { + future = raftClient.async().send(message); + RaftClientReply raftClientReply = future.get(); + return SCMRatisResponse.decode(raftClientReply); + } } - - } From 7a06e656dd3a0f890578e27fc18af36c7f3908cf Mon Sep 17 00:00:00 2001 From: Duong Nguyen Date: Wed, 7 Jun 2023 17:30:40 -0700 Subject: [PATCH 2/3] simplify. --- .../java/org/apache/hadoop/hdds/scm/ha/HASecurityUtils.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/HASecurityUtils.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/HASecurityUtils.java index 59322595cf89..3421861fe291 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/HASecurityUtils.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/HASecurityUtils.java @@ -351,9 +351,8 @@ public static SCMRatisResponse submitScmCertsToRatis(RaftGroup raftGroup, .setRetryPolicy( RetryPolicies.retryUpToMaximumCountWithFixedSleep(120, TimeDuration.valueOf(500, TimeUnit.MILLISECONDS))); - CompletableFuture future; try (RaftClient raftClient = builder.build()) { - future = raftClient.async().send(message); + CompletableFuture future = raftClient.async().send(message); RaftClientReply raftClientReply = future.get(); return SCMRatisResponse.decode(raftClientReply); } From 6ed99711e7caa4fe13dba184ab4e112bc6ae39d2 Mon Sep 17 00:00:00 2001 From: Duong Nguyen Date: Wed, 7 Jun 2023 17:47:06 -0700 Subject: [PATCH 3/3] checkstyle. --- .../java/org/apache/hadoop/hdds/scm/ha/HASecurityUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/HASecurityUtils.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/HASecurityUtils.java index 3421861fe291..ee25fc50c534 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/HASecurityUtils.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/HASecurityUtils.java @@ -352,7 +352,8 @@ public static SCMRatisResponse submitScmCertsToRatis(RaftGroup raftGroup, RetryPolicies.retryUpToMaximumCountWithFixedSleep(120, TimeDuration.valueOf(500, TimeUnit.MILLISECONDS))); try (RaftClient raftClient = builder.build()) { - CompletableFuture future = raftClient.async().send(message); + CompletableFuture future = + raftClient.async().send(message); RaftClientReply raftClientReply = future.get(); return SCMRatisResponse.decode(raftClientReply); }