Skip to content

Commit d18b0cc

Browse files
authored
FIX bindFreePort Bind Unable to bind to a free port (#559)
1 parent bc89f52 commit d18b0cc

1 file changed

Lines changed: 3 additions & 20 deletions

File tree

opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -721,30 +721,13 @@ private static ServerSocket bindPort(int port)
721721
throws IOException
722722
{
723723
ServerSocket serverLdapSocket;
724-
725-
serverLdapSocket = new ServerSocket();
726-
serverLdapSocket.setReuseAddress(true);
727-
serverLdapSocket.bind(new InetSocketAddress(port));
728-
serverLdapSocket.close();
729-
730724
serverLdapSocket = new ServerSocket();
731725
serverLdapSocket.setReuseAddress(true);
732-
serverLdapSocket.bind(new InetSocketAddress("localhost",port));
733-
serverLdapSocket.close();
734-
735-
736-
serverLdapSocket = new ServerSocket();
737-
serverLdapSocket.setReuseAddress(true);
738-
serverLdapSocket.bind(new InetSocketAddress(InetAddress.getLocalHost(),port));
739-
serverLdapSocket.close();
740-
741-
serverLdapSocket = new ServerSocket();
742-
serverLdapSocket.setReuseAddress(true);
743-
serverLdapSocket.bind(new InetSocketAddress("127.0.0.1",port));
726+
serverLdapSocket.bind(new InetSocketAddress(port));
744727
return serverLdapSocket;
745728
}
746729

747-
static int port = 30000;
730+
static int port = 65535;
748731
/**
749732
* Find and binds to a free server socket port on the local host. Avoid allocating ephemeral ports since these may
750733
* be used by client applications such as dsconfig. Instead scan through ports starting from a reasonably high number
@@ -757,7 +740,7 @@ private static ServerSocket bindPort(int port)
757740
*/
758741
public synchronized static ServerSocket bindFreePort() throws IOException
759742
{
760-
for (; port > 15000;)
743+
for (; port > 1024;)
761744
{
762745
try
763746
{

0 commit comments

Comments
 (0)