Skip to content

Commit

Permalink
refactor: inspect code of netty4 classes. (#10295)
Browse files Browse the repository at this point in the history
  • Loading branch information
stonelion authored Jul 11, 2022
1 parent dea2498 commit 5f35f0d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.dubbo.remoting.transport.netty4;

import io.netty.util.concurrent.EventExecutorGroup;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.Version;
import org.apache.dubbo.common.config.ConfigurationUtils;
Expand Down Expand Up @@ -68,7 +69,7 @@ public class NettyClient extends AbstractClient {
*/
private static final GlobalResourceInitializer<EventLoopGroup> EVENT_LOOP_GROUP = new GlobalResourceInitializer<>(() ->
eventLoopGroup(Constants.DEFAULT_IO_THREADS, "NettyClientWorker"),
eventLoopGroup -> eventLoopGroup.shutdownGracefully());
EventExecutorGroup::shutdownGracefully);

private Bootstrap bootstrap;

Expand Down Expand Up @@ -143,10 +144,7 @@ protected void initChannel(SocketChannel ch) throws Exception {

private boolean isFilteredAddress(String host) {
// filter local address
if (StringUtils.isEquals(NetUtils.getLocalHost(), host) || NetUtils.isLocalHost(host)) {
return true;
}
return false;
return StringUtils.isEquals(NetUtils.getLocalHost(), host) || NetUtils.isLocalHost(host);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class NettyServer extends AbstractServer {
private final int serverShutdownTimeoutMills;

public NettyServer(URL url, ChannelHandler handler) throws RemotingException {
// you can customize name and type of client thread pool by THREAD_NAME_KEY and THREADPOOL_KEY in CommonConstants.
// you can customize name and type of client thread pool by THREAD_NAME_KEY and THREAD_POOL_KEY in CommonConstants.
// the handler will be wrapped: MultiMessageHandler->HeartbeatHandler->handler
super(ExecutorUtil.setThreadName(url, SERVER_THREAD_POOL_NAME), ChannelHandlers.wrap(handler, url));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class NettyServerHandler extends ChannelDuplexHandler {
* the cache for alive worker channel.
* <ip:port, dubbo channel>
*/
private final Map<String, Channel> channels = new ConcurrentHashMap<String, Channel>();
private final Map<String, Channel> channels = new ConcurrentHashMap<>();

private final URL url;

Expand Down

0 comments on commit 5f35f0d

Please sign in to comment.