Repository: apache/dubbo
File: dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/AbstractNettyConnectionClient.java (Java)

Code before:

import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_CLIENT_CONNECT_TIMEOUT;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_CONNECT_PROVIDER;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_RECONNECT;

public abstract class AbstractNettyConnectionClient extends AbstractConnectionClient {

    private AtomicReference<Promise<Object>> connectingPromiseRef;

    private AtomicReference<io.netty.channel.Channel> channelRef;

    private Promise<Void> connectedPromise;

    private Promise<Void> disconnectedPromise;

    private Promise<Void> closePromise;

    private AtomicBoolean isReconnecting;

    private ConnectionListener connectionListener;

    public static final AttributeKey<AbstractConnectionClient> CONNECTION = AttributeKey.valueOf("connection");

    public AbstractNettyConnectionClient(URL url, ChannelHandler handler) throws RemotingException {
        super(url, handler);
    }

    @Override
    protected void doOpen() throws Throwable {
        initConnectionClient();
        initBootstrap();
    }

    @Override
    protected void initConnectionClient() {
        remote = getConnectAddress();
        init = new AtomicBoolean(false);
        connectingPromiseRef = new AtomicReference<>();
        channelRef = new AtomicReference<>();
        connectedPromise = new DefaultPromise<>(GlobalEventExecutor.INSTANCE);
        disconnectedPromise = new DefaultPromise<>(GlobalEventExecutor.INSTANCE);
        closePromise = new DefaultPromise<>(GlobalEventExecutor.INSTANCE);
        isReconnecting = new AtomicBoolean(false);
        connectionListener = new ConnectionListener();
        increase();
    }

    protected abstract void initBootstrap() throws Exception;

    @Override
    protected void doClose() {

Review comment (suggestion):
I think this logic should be added to `org.apache.dubbo.remoting.transport.netty4.NettyConnectionClient`, because HTTP/3 probably doesn't need it."

Code after:

import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_CLIENT_CONNECT_TIMEOUT;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_CONNECT_PROVIDER;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_RECONNECT;

public abstract class AbstractNettyConnectionClient extends AbstractConnectionClient {

    private AtomicReference<Promise<Object>> connectingPromiseRef;

    private AtomicReference<io.netty.channel.Channel> channelRef;

    private Promise<Void> connectedPromise;

    private Promise<Void> disconnectedPromise;

    private Promise<Void> closePromise;

    private AtomicBoolean isReconnecting;

    private ConnectionListener connectionListener;

    private AtomicReference<Promise<Void>> connectionPrefaceReceivedPromiseRef;

    public static final AttributeKey<AbstractConnectionClient> CONNECTION = AttributeKey.valueOf("connection");

    public AbstractNettyConnectionClient(URL url, ChannelHandler handler) throws RemotingException {
        super(url, handler);
    }

    @Override
    protected void doOpen() throws Throwable {
        initConnectionClient();
        initBootstrap();
    }

    @Override
    protected void initConnectionClient() {
        remote = getConnectAddress();
        init = new AtomicBoolean(false);
        connectingPromiseRef = new AtomicReference<>();
        channelRef = new AtomicReference<>();
        connectedPromise = new DefaultPromise<>(GlobalEventExecutor.INSTANCE);
        disconnectedPromise = new DefaultPromise<>(GlobalEventExecutor.INSTANCE);
        closePromise = new DefaultPromise<>(GlobalEventExecutor.INSTANCE);
        isReconnecting = new AtomicBoolean(false);
        connectionListener = new ConnectionListener();
        increase();

        // Create connection preface received promise for Http2 client since it should wait server http2 settings frame
        // before sending client Headers frame, see details at https://github.com/apache/dubbo/issues/15233
        if (protocol != null && protocol.hasConnectionPreface()) {