You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2015/02/09 16:36:23 UTC

[04/22] incubator-brooklyn git commit: Removed unnecessary double checking of free port

Removed unnecessary double checking of free port


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/34439f4a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/34439f4a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/34439f4a

Branch: refs/heads/master
Commit: 34439f4a2ac0c13781a8485c4d6d308fb744de47
Parents: 5004bfe
Author: Matt Champion <ma...@gmail.com>
Authored: Tue Jan 27 20:43:58 2015 +0000
Committer: Matt Champion <ma...@gmail.com>
Committed: Tue Jan 27 20:43:58 2015 +0000

----------------------------------------------------------------------
 .../src/main/java/brooklyn/util/net/Networking.java   | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/34439f4a/utils/common/src/main/java/brooklyn/util/net/Networking.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/brooklyn/util/net/Networking.java b/utils/common/src/main/java/brooklyn/util/net/Networking.java
index 2c7e4ff..828bb46 100644
--- a/utils/common/src/main/java/brooklyn/util/net/Networking.java
+++ b/utils/common/src/main/java/brooklyn/util/net/Networking.java
@@ -87,17 +87,6 @@ public class Networking {
 
         Stopwatch watch = Stopwatch.createStarted();
         try {
-            try {
-                Socket s = new Socket();
-                s.setSoTimeout(250);
-                s.connect(new InetSocketAddress(localAddressNotAny, port), 250);
-                try {
-                    s.close();
-                } catch (Exception e) {}
-                return false;
-            } catch (Exception e) {
-                //expected - shouldn't be able to connect
-            }
             //despite http://stackoverflow.com/questions/434718/sockets-discover-port-availability-using-java
             //(recommending the following) it isn't 100% reliable (e.g. nginx will happily coexist with ss+ds)
             //so we also do the above check
@@ -130,8 +119,7 @@ public class Networking {
                     }
                 }
             }
-            
-            
+
             if (localAddress==null || ANY_NIC.equals(localAddress)) {
                 // sometimes 0.0.0.0 can be bound to even if 127.0.0.1 has the port as in use;
                 // check all interfaces if 0.0.0.0 was requested