From e0d42df77b8b22657dba0605a960c4586bf6bfaa Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Sun, 23 Dec 2012 16:05:43 +0100 Subject: [PATCH] ServerBootstrap needs to have a localAddress defined --- .../main/java/io/netty/bootstrap/ServerBootstrap.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java b/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java index 5c76b1c2e7..1d02a1811c 100644 --- a/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java +++ b/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java @@ -33,9 +33,7 @@ import io.netty.channel.socket.SocketChannel; import io.netty.logging.InternalLogger; import io.netty.logging.InternalLoggerFactory; import io.netty.util.AttributeKey; -import io.netty.util.NetworkConstants; -import java.net.InetSocketAddress; import java.nio.channels.ClosedChannelException; import java.util.LinkedHashMap; import java.util.Map; @@ -48,7 +46,6 @@ import java.util.Map.Entry; public class ServerBootstrap extends AbstractBootstrap { private static final InternalLogger logger = InternalLoggerFactory.getInstance(ServerBootstrap.class); - private static final InetSocketAddress DEFAULT_LOCAL_ADDR = new InetSocketAddress(NetworkConstants.LOCALHOST, 0); private final ChannelHandler acceptor = new ChannelInitializer() { @Override @@ -211,14 +208,14 @@ public class ServerBootstrap extends AbstractBootstrap { if (childHandler == null) { throw new IllegalStateException("childHandler not set"); } + if (localAddress() == null) { + throw new IllegalStateException("localAddress not set"); + } if (childGroup == null) { logger.warn("childGroup is not set. Using parentGroup instead."); childGroup = group(); } - if (localAddress() == null) { - logger.warn("localAddress is not set. Using " + DEFAULT_LOCAL_ADDR + " instead."); - localAddress(DEFAULT_LOCAL_ADDR); - } + } private class Acceptor