Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.1
-
None
-
None
-
None
-
Core2duo, ubuntu gutsy (32bit), tomcat 6.0.13, sun's java 1.6.0_03.
Description
The XmlRpcClient javadocs says it's thread-safe. However, when I have 2 or more threads accessing it concurrently I get errors. The errors are often different and look very much like race errors IMHO.
Here is the client code:
public static void main( String[] args ) throws Exception {
final XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(MY_SERVER);
final XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
try {
final long stop=System.currentTimeMillis()+5000L;
for (int i=0; i<10; i++) {
final String id=""i": ";
new Thread(new Runnable() {
public void run() {
System.err.println("Started thread "+id);
try {
while ( System.currentTimeMillis() < stop ) {
System.err.println( id + client.execute( "echo.echo", new Object[]
) );
}
} catch ( XmlRpcException x )
}
}).start();
}
} catch (Exception x)
}
Here is the server code:
public class MyXmlRpcServlet extends XmlRpcServlet {
public static class EchoHandler {
public String echo( String msg )
}
@Override
protected XmlRpcHandlerMapping newXmlRpcHandlerMapping() throws XmlRpcException
Here are the first lines of a few of the errors I've got:
1)
Exception in thread "Thread-3" java.lang.RuntimeException: org.apache.xmlrpc.XmlRpcException: Failed to read servers response: Cannot write output after reading input.
at MyTest$1.run(MyTest.java:37)
at java.lang.Thread.run(Thread.java:595)
Caused by: org.apache.xmlrpc.XmlRpcException: Failed to read servers response: Cannot write output after reading input.
at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:150)
...
2)
Exception in thread "Thread-5" java.lang.RuntimeException: org.apache.xmlrpc.XmlRpcException: Failed to create input stream: Socket closed
at MyTest$1.run(MyTest.java:37)
at java.lang.Thread.run(Thread.java:595)
Caused by: org.apache.xmlrpc.XmlRpcException: Failed to create input stream: Socket closed
at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.getInputStream(XmlRpcSunHttpTransport.java:65)
...
3)
Exception in thread "Thread-2" java.lang.NullPointerException
at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:417)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:955)
at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.getInputStream(XmlRpcSunHttpTransport.java:63)
at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:141)
...
4)
[Fatal Error] :-1:-1: Premature end of file.
Exception in thread "Thread-9" java.lang.RuntimeException: org.apache.xmlrpc.client.XmlRpcClientException: Failed to parse servers response: Premature end of file.
at MyTest$1.run(MyTest.java:37)
at java.lang.Thread.run(Thread.java:595)
Caused by: org.apache.xmlrpc.client.XmlRpcClientException: Failed to parse servers response: Premature end of file.
at org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:177)