From 4fa0a6633adf4fe95df274e515ec03bac4c054ef Mon Sep 17 00:00:00 2001
From: elocatel <elocatel@localhost>
Date: Wed, 21 May 2008 15:22:12 +0000
Subject: [PATCH] Fix in getFreePort (again): use Java in jython instead of pure jython
---
opendj-sdk/opends/tests/shared/functions/utils.xml | 29 ++++++++++++++---------------
1 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/opendj-sdk/opends/tests/shared/functions/utils.xml b/opendj-sdk/opends/tests/shared/functions/utils.xml
index 498b878..a9ba108 100755
--- a/opendj-sdk/opends/tests/shared/functions/utils.xml
+++ b/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:
- s.close()
- port = port + 1
+ port = -1
+ break
+ try:
+ s = Socket(hostAddr, port)
+ s.close()
+ port = port + 1
+ except IOException, ioe:
+ break
</script>
<return>port</return>
</sequence>
--
Gitblit v1.10.0