Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always increment Stream Id on createStream #13485

Merged
merged 2 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -748,13 +748,16 @@ public boolean canOpenStream() {
public DefaultStream createStream(int streamId, boolean halfClosed) throws Http2Exception {
State state = activeState(streamId, IDLE, isLocal(), halfClosed);

checkNewStreamAllowed(streamId, state);
try {
checkNewStreamAllowed(streamId, state);
} finally {
// Always increment Expected stream ID
incrementExpectedStreamId(streamId);
}

// Create and initialize the stream.
DefaultStream stream = new DefaultStream(streamId, state);

incrementExpectedStreamId(streamId);

addStream(stream);

stream.activate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,21 @@ public void clientLocalIncrementAndGetStreamShouldRespectOverflow() throws Http2
incrementAndGetStreamShouldRespectOverflow(client.local(), MAX_VALUE);
}

@Test
public void incrementAndGetStreamShouldAlwaysIncrement() {
final int streamId = client.local().lastStreamKnownByPeer() + 1;

assertThrows(Http2Exception.class, new Executable() {
@Override
public void execute() throws Throwable {
client.local().createStream(streamId, true);
}
});

int nextStreamID = client.local().incrementAndGetNextStreamId();
assertEquals(streamId, nextStreamID - 3);
normanmaurer marked this conversation as resolved.
Show resolved Hide resolved
}

@Test
public void clientLocalCreateStreamExhaustedSpace() throws Http2Exception {
client.local().createStream(MAX_VALUE, true);
Expand Down