Skip to content

Commit

Permalink
okhttp: Remove finished stream even if a pending stream was started
Browse files Browse the repository at this point in the history
Fixes #11053
  • Loading branch information
hypnoce authored and ejona86 committed Mar 29, 2024
1 parent 2c52450 commit 385ebda
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -953,8 +953,8 @@ void finishStream(
}
if (!startPendingStreams()) {
stopIfNecessary();
maybeClearInUse(stream);
}
maybeClearInUse(stream);
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions okhttp/src/test/java/io/grpc/okhttp/OkHttpClientTransportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2080,6 +2080,26 @@ public void shutdownNow_streamListenerRpcProgress() throws Exception {
assertEquals(MISCARRIED, listener3.rpcProgress);
}

@Test
public void finishedStreamRemovedFromInUseState() throws Exception {
initTransport();
setMaxConcurrentStreams(1);
final MockStreamListener listener = new MockStreamListener();
OkHttpClientStream stream =
clientTransport.newStream(method, new Metadata(), CallOptions.DEFAULT, tracers);
stream.start(listener);
OkHttpClientStream pendingStream =
clientTransport.newStream(method, new Metadata(), CallOptions.DEFAULT, tracers);
pendingStream.start(listener);
waitForStreamPending(1);
clientTransport.finishStream(stream.transportState().id(), Status.OK, PROCESSED,
false, null, null);
verify(transportListener).transportInUse(true);
clientTransport.finishStream(pendingStream.transportState().id(), Status.OK, PROCESSED,
false, null, null);
verify(transportListener).transportInUse(false);
}

private int activeStreamCount() {
return clientTransport.getActiveStreams().length;
}
Expand Down

0 comments on commit 385ebda

Please sign in to comment.