This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 5b90ae700d1 HDDS-14830. Handle interrupt gracefully in 
XceiverClientGrpc.sendCommandWithRetry (#10178)
5b90ae700d1 is described below

commit 5b90ae700d119ff4b0cf3d5af4198d83aece5f82
Author: Chi-Hsuan Huang <[email protected]>
AuthorDate: Wed May 6 19:51:48 2026 +0800

    HDDS-14830. Handle interrupt gracefully in 
XceiverClientGrpc.sendCommandWithRetry (#10178)
---
 .../apache/hadoop/hdds/scm/XceiverClientGrpc.java  |  3 +++
 .../hadoop/hdds/scm/TestXceiverClientGrpc.java     | 27 ++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git 
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java
 
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java
index 1f9ac0a1226..8b1a99a6b66 100644
--- 
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java
+++ 
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java
@@ -542,6 +542,9 @@ private XceiverClientReply sendCommandWithRetry(
       } catch (InterruptedException e) {
         LOG.error("Command execution was interrupted ", e);
         Thread.currentThread().interrupt();
+        throw (IOException) new InterruptedIOException(
+            "Command " + processForDebug(request) + " was interrupted.")
+            .initCause(e);
       }
     }
 
diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/TestXceiverClientGrpc.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/TestXceiverClientGrpc.java
index 89ea363609d..0f3af071fc5 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/TestXceiverClientGrpc.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/TestXceiverClientGrpc.java
@@ -20,8 +20,10 @@
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.io.IOException;
+import java.io.InterruptedIOException;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -148,6 +150,31 @@ public XceiverClientReply sendCommandAsync(
     assertEquals(0, allDNs.size());
   }
 
+  @Test
+  public void testInterruptedCommandThrowsInterruptedIOException()
+      throws IOException {
+    final CompletableFuture<ContainerProtos.ContainerCommandResponseProto> 
response =
+        new CompletableFuture<>();
+    try (XceiverClientGrpc client = new XceiverClientGrpc(pipeline, conf) {
+      @Override
+      public XceiverClientReply sendCommandAsync(
+          ContainerProtos.ContainerCommandRequestProto request,
+          DatanodeDetails dn) {
+        return new XceiverClientReply(response);
+      }
+    }) {
+      Thread.currentThread().interrupt();
+      try {
+        InterruptedIOException ex = assertThrows(InterruptedIOException.class,
+            () -> invokeXceiverClientGetBlock(client));
+        assertThat(ex).hasCauseInstanceOf(InterruptedException.class);
+        assertThat(Thread.currentThread().isInterrupted()).isTrue();
+      } finally {
+        Thread.interrupted();
+      }
+    }
+  }
+
   @Test
   public void testFirstNodeIsCorrectWithTopologyForCommandTarget()
       throws IOException {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to