Dear all,
My concern is the confusion between the implementation of XmlRpcSunHttpTransport using the java.net.HttpURLConnection and the XmlRpcClientConfigImpl which rightfully specifies connection/read timeouts. The problem is that those are not forwarded to java.net.HttpURLConnection which supports those properties since java 1.5. A lot of us use java 1.5 and know that it supports it, therefore, we assume that it will just work. Unfortunately, it is not the case and we need to debug, download the source to check to realise it.

My proposition is to add the following in the class XmlRpcSunHttpTransport:

public Object sendRequest(XmlRpcRequest pRequest) throws XmlRpcException { XmlRpcHttpClientConfig config = (XmlRpcHttpClientConfig) pRequest.getConfig();
                try {
                        conn = newURLConnection(config.getServerURL());
                        conn.setUseCaches(false);
                        conn.setDoInput(true);
                        conn.setDoOutput(true);

                        //PROPOSED MODIFICATION START

//here we should reliably & elegantly check if we are running java 1.5
                        conn.setConnectTimeout(config.getConnectionTimeout());
                        conn.setReadTimeout(config.getReplyTimeout());

                        //PROPOSED MODIFICATION STOP

        } catch (IOException e) {
throw new XmlRpcException("Failed to create URLConnection: " + e.getMessage(), e);
        }
        return super.sendRequest(pRequest);
}

I didn't find a nice way of detecting if we have a higher version of JRE instead of parsing java.version. Anyone knows?

Best Regards,
Gam.

PS: Little rant:
I still think that the Apache XML-RPC library as lost a bit of the spirit of the xmlrpc protocol (its simplicity) with the release of v3.x. I noticed that my request for a simple class (ObjectHandlerMapping) to let us use object as handler didn't get much attention, but I'm still trying :o)

Reply via email to