This is an automated email from the ASF dual-hosted git repository.
szetszwo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ratis.git
The following commit(s) were added to refs/heads/master by this push:
new 70e2e3231 RATIS-2412. NettyClient LoggingHandler not working. (#1353)
70e2e3231 is described below
commit 70e2e323140900180cc2fd116f3354f420ed897d
Author: slfan1989 <[email protected]>
AuthorDate: Thu Feb 19 05:23:13 2026 +0800
RATIS-2412. NettyClient LoggingHandler not working. (#1353)
---
ratis-netty/src/main/java/org/apache/ratis/netty/NettyClient.java | 4 ----
ratis-netty/src/main/java/org/apache/ratis/netty/NettyRpcProxy.java | 5 ++++-
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/ratis-netty/src/main/java/org/apache/ratis/netty/NettyClient.java
b/ratis-netty/src/main/java/org/apache/ratis/netty/NettyClient.java
index a42ddaca8..56ca6b030 100644
--- a/ratis-netty/src/main/java/org/apache/ratis/netty/NettyClient.java
+++ b/ratis-netty/src/main/java/org/apache/ratis/netty/NettyClient.java
@@ -24,8 +24,6 @@ import
org.apache.ratis.thirdparty.io.netty.channel.ChannelFuture;
import org.apache.ratis.thirdparty.io.netty.channel.ChannelInitializer;
import org.apache.ratis.thirdparty.io.netty.channel.EventLoopGroup;
import org.apache.ratis.thirdparty.io.netty.channel.socket.SocketChannel;
-import org.apache.ratis.thirdparty.io.netty.handler.logging.LogLevel;
-import org.apache.ratis.thirdparty.io.netty.handler.logging.LoggingHandler;
import org.apache.ratis.util.JavaUtils;
import org.apache.ratis.util.LifeCycle;
import org.apache.ratis.util.NetUtils;
@@ -47,12 +45,10 @@ public class NettyClient implements Closeable {
public void connect(EventLoopGroup group, ChannelInitializer<SocketChannel>
initializer)
throws InterruptedException {
final InetSocketAddress address = NetUtils.createSocketAddr(serverAddress);
-
lifeCycle.startAndTransition(
() -> channel = new Bootstrap()
.group(group)
.channel(NettyUtils.getSocketChannelClass(group))
- .handler(new LoggingHandler(LogLevel.INFO))
.handler(initializer)
.connect(address)
.sync()
diff --git
a/ratis-netty/src/main/java/org/apache/ratis/netty/NettyRpcProxy.java
b/ratis-netty/src/main/java/org/apache/ratis/netty/NettyRpcProxy.java
index f77096e18..675e0e1fe 100644
--- a/ratis-netty/src/main/java/org/apache/ratis/netty/NettyRpcProxy.java
+++ b/ratis-netty/src/main/java/org/apache/ratis/netty/NettyRpcProxy.java
@@ -31,6 +31,8 @@ import org.apache.ratis.proto.RaftProtos.RaftRpcRequestProto;
import org.apache.ratis.proto.netty.NettyProtos.RaftNettyServerReplyProto;
import org.apache.ratis.proto.netty.NettyProtos.RaftNettyServerRequestProto;
import org.apache.ratis.protocol.exceptions.AlreadyClosedException;
+import org.apache.ratis.thirdparty.io.netty.handler.logging.LogLevel;
+import org.apache.ratis.thirdparty.io.netty.handler.logging.LoggingHandler;
import org.apache.ratis.util.IOUtils;
import org.apache.ratis.util.PeerProxyMap;
import org.apache.ratis.util.ProtoUtils;
@@ -141,9 +143,10 @@ public class NettyRpcProxy implements Closeable {
final ChannelInitializer<SocketChannel> initializer
= new ChannelInitializer<SocketChannel>() {
@Override
- protected void initChannel(SocketChannel ch) throws Exception {
+ protected void initChannel(SocketChannel ch) {
final ChannelPipeline p = ch.pipeline();
+ p.addLast(new LoggingHandler(LogLevel.WARN));
p.addLast(new ProtobufVarint32FrameDecoder());
p.addLast(new
ProtobufDecoder(RaftNettyServerReplyProto.getDefaultInstance()));
p.addLast(new ProtobufVarint32LengthFieldPrepender());