Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
Loading