You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "szetszwo (via GitHub)" <gi...@apache.org> on 2025/11/16 22:03:28 UTC

Re: [PR] HDDS 13939. Potential channel leak in StreamingClient.stream() method [ozone]

szetszwo commented on code in PR #9304:
URL: https://github.com/apache/ozone/pull/9304#discussion_r2532269951


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/stream/StreamingClient.java:
##########
@@ -86,11 +86,17 @@ public void stream(String id) {
   }
 
   public void stream(String id, long timeout, TimeUnit unit) {
+    Channel channel = null;
     try {
-      Channel channel = bootstrap.connect(host, port).sync().channel();
-      channel.writeAndFlush(id + "\n")
-          .await(timeout, unit);
-      channel.closeFuture().await(timeout, unit);
+      channel = bootstrap.connect(host, port).sync().channel();
+      boolean writeSuccess = channel.writeAndFlush(id + "\n").await(timeout, unit);
+      if (!writeSuccess) {
+        throw new StreamingException("Write operation timed out");

Review Comment:
   Let's include more information in the error message
   ```java
   "Failed to write id " + id + ": timed out " + timeout + " " + unit
   ```



##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/stream/StreamingClient.java:
##########
@@ -86,11 +86,17 @@ public void stream(String id) {
   }
 
   public void stream(String id, long timeout, TimeUnit unit) {
+    Channel channel = null;
     try {
-      Channel channel = bootstrap.connect(host, port).sync().channel();
-      channel.writeAndFlush(id + "\n")
-          .await(timeout, unit);
-      channel.closeFuture().await(timeout, unit);
+      channel = bootstrap.connect(host, port).sync().channel();
+      boolean writeSuccess = channel.writeAndFlush(id + "\n").await(timeout, unit);
+      if (!writeSuccess) {
+        throw new StreamingException("Write operation timed out");
+      }
+      boolean closeSuccess = channel.closeFuture().await(timeout, unit);
+      if (!closeSuccess) {
+        throw new StreamingException("Close operation timed out");

Review Comment:
   Similarly,
   ```java
   "Failed to close channel for id " + id + ": timed out " + timeout + " " + unit
   ```



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org