Skip to content

Commit

Permalink
bugfix: let getListenPort() always get the exact value
Browse files Browse the repository at this point in the history
  • Loading branch information
skyesx committed Jan 12, 2019
1 parent 1593308 commit f38c35e
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
import java.net.InetSocketAddress;
import java.util.concurrent.ThreadPoolExecutor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.fescar.common.thread.NamedThreadFactory;
import com.alibaba.fescar.core.rpc.RemotingServer;

Expand All @@ -34,8 +37,6 @@
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.timeout.IdleStateHandler;
import io.netty.util.concurrent.DefaultEventExecutorGroup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* The type Rpc remoting server.
Expand Down Expand Up @@ -98,6 +99,8 @@ public AbstractRpcRemotingServer(final NettyServerConfig nettyServerConfig,
if (null != handlers) {
channelHandlers = handlers;
}
// init listenPort in constructor so that getListenPort() will always get the exact port
listenPort = nettyServerConfig.getDefaultListenPort();

}

Expand All @@ -107,9 +110,7 @@ public void start() {
nettyServerConfig.getServerWorkerThreads(),
new NamedThreadFactory(nettyServerConfig.getExecutorThreadPrefix(),
nettyServerConfig.getServerWorkerThreads()));
if (listenPort == 0) {
listenPort = nettyServerConfig.getDefaultListenPort();
}

this.serverBootstrap.group(this.eventLoopGroupBoss, this.eventLoopGroupWorker)
.channel(nettyServerConfig.SERVER_CHANNEL_CLAZZ)
.option(ChannelOption.SO_BACKLOG, nettyServerConfig.getSoBackLogSize())
Expand Down

0 comments on commit f38c35e

Please sign in to comment.