Skip to content

Commit 3f87103

Browse files
committed
servlet: fix write when not ready in AsyncServletOutputStreamWriter
Fixes #12723
1 parent f430131 commit 3f87103

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

servlet/src/main/java/io/grpc/servlet/AsyncServletOutputStreamWriter.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,11 @@ private void runOrBuffer(ActionItem actionItem) throws IOException {
222222
if (actionItem == completeAction) {
223223
return;
224224
}
225-
if (!isReady.getAsBoolean()) {
226-
boolean successful =
227-
writeState.compareAndSet(curState, curState.withReadyAndDrained(false));
228-
LockSupport.unpark(parkingThread);
229-
checkState(successful, "Bug: curState is unexpectedly changed by another thread");
230-
log.finest("the servlet output stream becomes not ready");
231-
}
225+
boolean successful =
226+
writeState.compareAndSet(curState, curState.withReadyAndDrained(false));
227+
LockSupport.unpark(parkingThread);
228+
checkState(successful, "Bug: curState is unexpectedly changed by another thread");
229+
log.finest("the servlet output stream becomes not ready");
232230
} else { // buffer to the writeChain
233231
writeChain.offer(actionItem);
234232
if (!writeState.compareAndSet(curState, curState.withReadyAndDrained(false))) {

0 commit comments

Comments
 (0)