Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

whether multiple calls to the Bootstrap.handler() method are effective? #84

Open
R1C4D0 opened this issue Sep 9, 2024 · 0 comments
Open

Comments

@R1C4D0
Copy link

R1C4D0 commented Sep 9, 2024

I noticed that in the no-argument constructor of the NettyRpcClient class, the bootstrap.handler() method is called twice. Will the ChannelInitializer added by the second call overwrite the LoggingHandler added by the first call?

public NettyRpcClient() {
//....
Bootstrap bootstrap = = new Bootstrap();
bootstrap
.handler(new LoggingHandler(LogLevel.INFO))
//...
.handler(new ChannelInitializer() {
@OverRide
protected void initChannel(SocketChannel ch) {
ChannelPipeline p = ch.pipeline();
// If no data is sent to the server within 15 seconds, a heartbeat request is sent
p.addLast(new IdleStateHandler(0, 5, 0, TimeUnit.SECONDS));
p.addLast(new RpcMessageEncoder());
p.addLast(new RpcMessageDecoder());
p.addLast(new NettyRpcClientHandler());
}
});
}

The handler() method of the Bootstrap class is as follows:

public B handler(ChannelHandler handler) {
this.handler = ObjectUtil.checkNotNull(handler, "handler");
return self();
}
Will the second handler overwrite the first handler?

@R1C4D0 R1C4D0 closed this as completed Sep 9, 2024
@R1C4D0 R1C4D0 reopened this Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant