You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by aa...@apache.org on 2019/08/23 02:54:54 UTC

[pulsar] branch port_manager created (now 9e55a68)

This is an automated email from the ASF dual-hosted git repository.

aahmed pushed a change to branch port_manager
in repository https://gitbox.apache.org/repos/asf/pulsar.git.


      at 9e55a68  Fix Port Manager

This branch includes the following new commits:

     new 9e55a68  Fix Port Manager

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[pulsar] 01/01: Fix Port Manager

Posted by aa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aahmed pushed a commit to branch port_manager
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit 9e55a6877c03ede6b427b051af77a8a19fa65de3
Author: Ali Ahmed <al...@gmail.com>
AuthorDate: Thu Aug 22 18:23:42 2019 -0700

    Fix Port Manager
---
 .../src/test/java/org/apache/bookkeeper/test/PortManager.java     | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/test/PortManager.java b/managed-ledger/src/test/java/org/apache/bookkeeper/test/PortManager.java
index a18cc04..65c11f5 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/test/PortManager.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/test/PortManager.java
@@ -21,6 +21,8 @@ package org.apache.bookkeeper.test;
 import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
 import java.net.ServerSocket;
 import java.nio.CharBuffer;
 import java.nio.channels.FileChannel;
@@ -37,7 +39,7 @@ public class PortManager {
 
     private static final String lockFilename = System.getProperty("test.lockFilename",
             "/tmp/pulsar-test-port-manager.lock");
-    private static final int basePort = Integer.valueOf(System.getProperty("test.basePort", "15000"));
+    private static final int basePort = Integer.parseInt(System.getProperty("test.basePort", "15000"));
 
     private static final int maxPort = 32000;
 
@@ -95,7 +97,9 @@ public class PortManager {
                 port = basePort;
             }
 
-            try (ServerSocket ss = new ServerSocket(port)) {
+            try (ServerSocket ss = new ServerSocket()) {
+                ss.setReuseAddress(false);
+                ss.bind(new InetSocketAddress(InetAddress.getByName("localhost"), port), 1);
                 ss.close();
                 // Give it some time to truly close the connection
                 Thread.sleep(100);