From 1641514c76706a98eb2ce4f40c4da4b1cf73dca7 Mon Sep 17 00:00:00 2001 From: Violeta Georgieva Date: Mon, 6 Jan 2025 19:16:20 +0200 Subject: [PATCH] Ensure DisposedChannelConfig#setAutoRead does not change auto-read configuration (#3581) 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 --- .../netty/channel/ChannelOperations.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/reactor-netty-core/src/main/java/reactor/netty/channel/ChannelOperations.java b/reactor-netty-core/src/main/java/reactor/netty/channel/ChannelOperations.java index 9603508beb..47c14cb133 100644 --- a/reactor-netty-core/src/main/java/reactor/netty/channel/ChannelOperations.java +++ b/reactor-netty-core/src/main/java/reactor/netty/channel/ChannelOperations.java @@ -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. @@ -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(); } @@ -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;