the following patch makes XmlRpc running with codec 1.2.
Comments inline. (And I'm all for "letting it suck" -- +1 on a little less elegance over interoperability any day.)
Index: DefaultTypeFactory.java =================================================================== RCS file: /home/cvspublic/ws-xmlrpc/src/java/org/apache/xmlrpc/DefaultTypeFactory.java,v retrieving revision 1.3 diff -u -r1.3 DefaultTypeFactory.java --- DefaultTypeFactory.java 1 May 2003 16:53:15 -0000 1.3 +++ DefaultTypeFactory.java 15 Jun 2004 20:24:10 -0000 @@ -128,7 +128,7 @@ public Object createBase64(String cdata) { try { - return base64Codec.decode(cdata.getBytes()); + return base64Codec.decode((Object) cdata.getBytes());
This cast looks unnecessary. What's the thinking here?
} catch (DecoderException e) { //TODO: consider throwing an exception here? Index: XmlWriter.java =================================================================== RCS file: /home/cvspublic/ws-xmlrpc/src/java/org/apache/xmlrpc/XmlWriter.java,v retrieving revision 1.9 diff -u -r1.9 XmlWriter.java --- XmlWriter.java 12 Sep 2003 09:44:06 -0000 1.9 +++ XmlWriter.java 15 Jun 2004 20:24:13 -0000 @@ -212,7 +212,7 @@ { startElement("base64"); try { - this.write(base64Codec.encode((byte[]) obj)); + this.write((byte[]) base64Codec.encode(obj));
This hack should have an inline comment above it.
} catch (EncoderException e) { throw new XmlRpcClientException("Unable to Base 64 encode byte array", e); Index: applet/SimpleXmlRpcClient.java =================================================================== RCS file: /home/cvspublic/ws-xmlrpc/src/java/org/apache/xmlrpc/applet/SimpleXmlRpcClient.java,v retrieving revision 1.8 diff -u -r1.8 SimpleXmlRpcClient.java --- applet/SimpleXmlRpcClient.java 14 May 2004 15:47:05 -0000 1.8 +++ applet/SimpleXmlRpcClient.java 15 Jun 2004 20:24:15 -0000 @@ -250,7 +250,7 @@ { writer.startElement("base64"); try { - writer.write(base64.encode((byte[]) what)); + writer.write((byte[]) base64.encode(what));
Ditto.
} catch (EncoderException e) { throw new RuntimeException("Incompatible version of org.apache.commons.codec.binary.Base64 used, and an error occurred."); @@ -648,7 +648,7 @@ break; case BASE64: try { - value = base64.decode(cdata.getBytes()); + value = base64.decode((Object) cdata.getBytes());
Why is this cast necessary? If base64.decode() takes an Object, the byte[] reference should do just fine.
} catch (DecoderException e) { /* FIXME: what should we do here? Probably an Exception? Index: util/HttpUtil.java =================================================================== RCS file: /home/cvspublic/ws-xmlrpc/src/java/org/apache/xmlrpc/util/HttpUtil.java,v retrieving revision 1.2 diff -u -r1.2 HttpUtil.java --- util/HttpUtil.java 1 May 2003 16:53:16 -0000 1.2 +++ util/HttpUtil.java 15 Jun 2004 20:24:15 -0000 @@ -86,8 +86,8 @@ else { try { - auth = new String(base64.encode((user + ':' + password) - .getBytes())).trim(); + byte[] bytes = (byte[]) (user + ':' + password).getBytes(); + auth = new String((byte[]) base64.encode((Object) bytes)).trim();
Another cast from byte[] to Object...
} catch (EncoderException e) { // EncoderException is never thrown in the body of Base64.encode(byte[]) in version 1.1