Skip to content

Commit 9cddcb4

Browse files
authored
stub: remove interrupt checking from ThreadSafeThreadlessExecutor.drain (#12358)
The only caller of `drain()` just reset the interrupt flag. So, we can avoid the whole exception dance.
1 parent 1937ef8 commit 9cddcb4

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

stub/src/main/java/io/grpc/stub/BlockingClientCall.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public void halfClose() {
273273
*/
274274
@VisibleForTesting
275275
Status getClosedStatus() {
276-
drainQuietly();
276+
executor.drain();
277277
CloseState state = closeState.get();
278278
return (state == null) ? null : state.status;
279279
}
@@ -295,7 +295,7 @@ boolean isEitherReadOrWriteReady() {
295295
*/
296296
@VisibleForTesting
297297
boolean isReadReady() {
298-
drainQuietly();
298+
executor.drain();
299299

300300
return !buffer.isEmpty();
301301
}
@@ -308,7 +308,7 @@ boolean isReadReady() {
308308
*/
309309
@VisibleForTesting
310310
boolean isWriteReady() {
311-
drainQuietly();
311+
executor.drain();
312312

313313
return isWriteLegal() && call.isReady();
314314
}
@@ -325,14 +325,6 @@ ClientCall.Listener<RespT> getListener() {
325325
return new QueuingListener();
326326
}
327327

328-
private void drainQuietly() {
329-
try {
330-
executor.drain();
331-
} catch (InterruptedException e) {
332-
Thread.currentThread().interrupt();
333-
}
334-
}
335-
336328
private final class QueuingListener extends ClientCall.Listener<RespT> {
337329
@Override
338330
public void onMessage(RespT value) {

stub/src/main/java/io/grpc/stub/ClientCalls.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -935,11 +935,8 @@ public <T> void waitAndDrainWithTimeout(boolean waitForever, long end,
935935
}
936936
}
937937

938-
/**
939-
* Executes all queued Runnables and if there were any wakes up any waiting threads.
940-
*/
941-
public void drain() throws InterruptedException {
942-
throwIfInterrupted();
938+
/** Executes all queued Runnables and if there were any wakes up any waiting threads. */
939+
void drain() {
943940
Runnable runnable;
944941
boolean didWork = false;
945942

0 commit comments

Comments
 (0)