You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlrpc-auto@ws.apache.org by "Marcus Sundman (JIRA)" <xm...@ws.apache.org> on 2008/01/13 00:22:34 UTC
[jira] Commented: (XMLRPC-150) XmlRpcClient is not thread-safe
[ https://issues.apache.org/jira/browse/XMLRPC-150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12558312#action_12558312 ]
Marcus Sundman commented on XMLRPC-150:
---------------------------------------
Yup, seems to be fixed. Or at least 3.1.1-20071027.183056-3 doesn't throw the same exceptions anymore.
> XmlRpcClient is not thread-safe
> -------------------------------
>
> Key: XMLRPC-150
> URL: https://issues.apache.org/jira/browse/XMLRPC-150
> Project: XML-RPC
> Issue Type: Bug
> Affects Versions: 3.1
> Environment: Core2duo, ubuntu gutsy (32bit), tomcat 6.0.13, sun's java 1.6.0_03.
> Reporter: Marcus Sundman
>
> 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[]{id+"foo"} ) );
> }
> } catch ( XmlRpcException x ) {
> throw new RuntimeException( x );
> }
> }
> }).start();
> }
> } catch (Exception x) {
> x.printStackTrace();
> }
> }
> Here is the server code:
> public class MyXmlRpcServlet extends XmlRpcServlet {
> public static class EchoHandler {
> public String echo( String msg ) {
> return msg;
> }
> }
> @Override
> protected XmlRpcHandlerMapping newXmlRpcHandlerMapping() throws XmlRpcException {
> PropertyHandlerMapping handlers =new PropertyHandlerMapping();
> handlers.addHandler( "echo", EchoHandler.class );
> return handlers;
> }
> 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)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.