mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

elocatel
21.22.2008 4fa0a6633adf4fe95df274e515ec03bac4c054ef
Fix in getFreePort (again): use Java in jython instead of pure jython
1 files modified
21 ■■■■ changed files
opendj-sdk/opends/tests/shared/functions/utils.xml 21 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/tests/shared/functions/utils.xml
@@ -2103,25 +2103,24 @@
      <script>
        # returns first free port in [port; port+5]
        # if no free port in this interval, return -1
        import socket
        import sys
        s = None
        from java.net import Socket
        from java.net import InetAddress
        from java.io  import IOException
        hostAddr = InetAddress.getByName(host)
        i = 0
        while 1:
          try:
            i = i + 1
            if i > 5:
              port = -1
              break
            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            s.bind((host, port))
            s.listen(1)
            s.close()
            break
          except socket.error:
            if s:
            try:
                s = Socket(hostAddr, port)
              s.close()
            port = port + 1
            except IOException, ioe:
                break
      </script>
      <return>port</return>
    </sequence>