Skip to content

ChannelClosedException when server close connection right after releasing the last http2 stream #6258

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class HttpOrHttp2ChannelPool implements SdkChannelPool {

private boolean protocolImplPromiseInitializationStarted = false;
private Promise<ChannelPool> protocolImplPromise;
private BetterFixedChannelPool protocolImpl;
private volatile BetterFixedChannelPool protocolImpl;
private boolean closed;

public HttpOrHttp2ChannelPool(ChannelPool delegatePool,
Expand Down Expand Up @@ -194,9 +194,12 @@ public Future<Void> release(Channel channel) {

@Override
public Future<Void> release(Channel channel, Promise<Void> promise) {
doInEventLoop(eventLoop,
() -> release0(channel, promise),
promise);
// If protocolImpl != null, it’s already visible, so we call protocolImpl.release
// directly in the channel event loop. Otherwise — whether unassigned or not yet
// visible — we fall back to the safe path. Since protocolImpl is assigned only
// once, there's no risk of calling it on an incorrect instance.
if (protocolImpl != null) protocolImpl.release(channel, promise);
else doInEventLoop(eventLoop, () -> release0(channel, promise), promise);
return promise;
}

Expand Down