Skip to content
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