Skip to content

Commit ed6d175

Browse files
authored
okhttp: Assert no pending streams before transport READY (#12566)
### What this PR does Based on guidance from maintainers and what I have observed in the OkHttpClientTransport lifecycle, it seems that no pending streams should exist when the transport transitions to READY. This PR adds an assertion to help verify this invariant. --- ### Note on Testing All existing tests pass with this assertion in place. --- This PR corresponds to **Step 2** of the plan discussed in #11985, by adding an explicit assertion to help ensure the transport readiness invariant. Fixes #11985
1 parent 24bd540 commit ed6d175

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

okhttp/src/main/java/io/grpc/okhttp/OkHttpClientTransport.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,9 @@ public void run() {
802802
}
803803
synchronized (lock) {
804804
maxConcurrentStreams = Integer.MAX_VALUE;
805-
startPendingStreams();
805+
checkState(pendingStreams.isEmpty(),
806+
"Pending streams detected during transport start."
807+
+ " RPCs should not be started before transport is ready.");
806808
}
807809
// ClientFrameHandler need to be started after connectionPreface / settings, otherwise it
808810
// may send goAway immediately.

0 commit comments

Comments
 (0)