Skip to content

Commit

Permalink
Ensure DisposedChannelConfig#setAutoRead does not change auto-read co…
Browse files Browse the repository at this point in the history
…nfiguration

DisposedChannel is effective when request/response is terminated and replaces the actual channel.
At that point DisposedChannelConfig#setAutoRead must be non operational
as the inbound has already been read and the actual channel has already set auto-read to true.

The issue is also observed with the reproducible example provided by #3495

Fixes #3559
  • Loading branch information
violetagg committed Jan 6, 2025
1 parent b308887 commit bbd818d
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2024 VMware, Inc. or its affiliates, All Rights Reserved.
* Copyright (c) 2011-2025 VMware, Inc. or its affiliates, All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -704,7 +704,7 @@ static final class DisposedChannel extends AbstractChannel {
DisposedChannel(Channel actual) {
super(null);
this.metadata = actual.metadata();
this.config = new DefaultChannelConfig(this);
this.config = new DisposedChannelConfig(this);
this.localAddress = actual.localAddress();
this.remoteAddress = actual.remoteAddress();
}
Expand Down Expand Up @@ -788,6 +788,19 @@ public void connect(SocketAddress remoteAddress, SocketAddress localAddress, Cha
}
}

static final class DisposedChannelConfig extends DefaultChannelConfig {

DisposedChannelConfig(Channel channel) {
super(channel);
}

@Override
public ChannelConfig setAutoRead(boolean autoRead) {
// no-op
return this;
}
}

static final class DisposedConnection implements Connection {

final Channel channel;
Expand Down

0 comments on commit bbd818d

Please sign in to comment.