From 9f62516c58f39f74b4dcb9328bfd5a5d003d3814 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 27 Apr 2010 19:24:58 +0000 Subject: [PATCH] 310634 git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1613 7e9141cc-0065-0410-87d8-b60c137991c4 --- .../src/main/java/org/eclipse/jetty/server/Connector.java | 4 ++-- .../java/org/eclipse/jetty/server/bio/SocketConnector.java | 3 +++ .../org/eclipse/jetty/server/nio/SelectChannelConnector.java | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Connector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Connector.java index 5328a1a1433..827e78ca581 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Connector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Connector.java @@ -212,8 +212,8 @@ public interface Connector extends LifeCycle /* ------------------------------------------------------------ */ /** - * @return The actual port the connector is listening on or -1 if there - * is no port or the connector is not open. + * @return The actual port the connector is listening on or + * -1 if it has not been opened, or -2 if it has been closed. */ int getLocalPort(); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/bio/SocketConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/bio/SocketConnector.java index fccd726e6bf..99b8f0a5988 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/bio/SocketConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/bio/SocketConnector.java @@ -75,6 +75,9 @@ public class SocketConnector extends AbstractConnector _serverSocket= newServerSocket(getHost(),getPort(),getAcceptQueueSize()); _serverSocket.setReuseAddress(getReuseAddress()); _localPort=_serverSocket.getLocalPort(); + if (_localPort<=0) + throw new IllegalStateException("port not allocated for "+this); + } /* ------------------------------------------------------------ */ diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/nio/SelectChannelConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/nio/SelectChannelConnector.java index a464f9c2e85..a091951819c 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/nio/SelectChannelConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/nio/SelectChannelConnector.java @@ -210,7 +210,7 @@ public class SelectChannelConnector extends AbstractNIOConnector _acceptChannel.socket().bind(addr,getAcceptQueueSize()); _localPort=_acceptChannel.socket().getLocalPort(); - if (_localPort==-1) + if (_localPort<=0) throw new IOException("Server channel not bound"); // Set to non blocking mode