James Russo wrote:
> I likely won't be the only one to point this out, but no patch was
> attached.
Silly me. :-) Thank you, here it is.
? bin
? lib
Index: src/java/org/apache/xmlrpc/WebServer.java
===================================================================
RCS file: /home/cvspublic/ws-xmlrpc/src/java/org/apache/xmlrpc/WebServer.java,v
retrieving revision 1.26
diff -u -b -r1.26 WebServer.java
--- src/java/org/apache/xmlrpc/WebServer.java 17 Jun 2004 01:49:10 -0000 1.26
+++ src/java/org/apache/xmlrpc/WebServer.java 31 Mar 2005 21:36:00 -0000
@@ -304,6 +304,17 @@
*/
public void start()
{
+ try
+ {
+ setupServerSocket(50);
+ }
+ catch (Exception e)
+ {
+ listener = null;
+ e.printStackTrace();
+ throw new RuntimeException(e.getMessage());
+ }
+
// The listener reference is released upon shutdown().
if (listener == null)
{
@@ -470,17 +481,6 @@
{
try
{
- setupServerSocket(50);
- }
- catch (Exception e)
- {
- listener = null;
- e.printStackTrace();
- throw new RuntimeException(e.getMessage());
- }
-
- try
- {
while (listener != null)
{
try
Index: src/test/org/apache/xmlrpc/ClientServerRpcTest.java
===================================================================
RCS file: /home/cvspublic/ws-xmlrpc/src/test/org/apache/xmlrpc/ClientServerRpcTest.java,v
retrieving revision 1.16
diff -u -b -r1.16 ClientServerRpcTest.java
--- src/test/org/apache/xmlrpc/ClientServerRpcTest.java 17 Jun 2004 01:40:14 -0000 1.16
+++ src/test/org/apache/xmlrpc/ClientServerRpcTest.java 31 Mar 2005 21:36:04 -0000
@@ -123,18 +123,6 @@
server = new XmlRpcServer();
server.addHandler(HANDLER_NAME, new TestHandler());
- InetAddress localhost = null;
- try
- {
- // localhost will be a random network interface on a
- // multi-homed host.
- localhost = InetAddress.getLocalHost();
- }
- catch (UnknownHostException e)
- {
- fail(e.toString());
- }
-
// Setup system handler
SystemHandler webServerSysHandler = new SystemHandler();
webServerSysHandler.addSystemHandler("multicall", new MultiCall());
@@ -142,19 +130,6 @@
// WebServer (contains its own XmlRpcServer instance)
setUpWebServer();
webServer.addHandler("system", webServerSysHandler);
-
- // XML-RPC client(s)
- try
- {
- String hostName = localhost.getHostName();
- client = new XmlRpcClient(hostName, SERVER_PORT);
- //liteClient = new XmlRpcClientLite(hostName, SERVER_PORT);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- fail(e.toString());
- }
}
/**
@@ -179,6 +154,31 @@
e.printStackTrace();
fail(e.toString());
}
+
+ InetAddress localhost = null;
+ try
+ {
+ // localhost will be a random network interface on a
+ // multi-homed host.
+ localhost = InetAddress.getLocalHost();
+ }
+ catch (UnknownHostException e)
+ {
+ fail(e.toString());
+ }
+
+ // XML-RPC client(s)
+ try
+ {
+ String hostName = localhost.getHostName();
+ client = new XmlRpcClient(hostName, SERVER_PORT);
+ //liteClient = new XmlRpcClientLite(hostName, SERVER_PORT);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail(e.toString());
+ }
}
/**
Index: src/test/org/apache/xmlrpc/LocalServerRpcTest.java
===================================================================
RCS file: /home/cvspublic/ws-xmlrpc/src/test/org/apache/xmlrpc/LocalServerRpcTest.java,v
retrieving revision 1.1
diff -u -b -r1.1 LocalServerRpcTest.java
--- src/test/org/apache/xmlrpc/LocalServerRpcTest.java 26 Jan 2003 02:31:08 -0000 1.1
+++ src/test/org/apache/xmlrpc/LocalServerRpcTest.java 31 Mar 2005 21:36:04 -0000
@@ -78,7 +78,7 @@
*/
protected static final String REQUEST_PARAM_VALUE = "foobar";
- protected static final int SERVER_PORT;
+ protected static int SERVER_PORT;
/**
* The value to use in our request parameter.
@@ -100,16 +100,6 @@
super(message);
}
- /**
- * Static constructor
- * - initializes test port
- *
- * TODO: can we initialize this from a properties file?
- */
- static {
- SERVER_PORT = 8081;
- }
-
protected WebServer webServer;
/**
@@ -134,6 +124,7 @@
*/
protected void startWebServer() {
webServer.start();
+ SERVER_PORT = webServer.serverSocket.getLocalPort();
}
/**