Commits

James Dumay  committed 8bae248

Collection->array conversion

  • Participants
  • Parent commits b591ab8

Comments (0)

Files changed (1)

File src/main/java/com/atlassian/xmlrpc/RPCCallMethodInterceptor.java

  */
 
 import java.lang.reflect.Method;
-import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Vector;
 import net.sf.cglib.proxy.MethodInterceptor;
 import net.sf.cglib.proxy.MethodProxy;
     public Object intercept(Object object, Method method, Object[] args, MethodProxy proxy) 
         throws Throwable 
     {
+        final String methodName = getMethodName(method);
         try
         {
-            return client.execute(serviceObject + "." + getMethodName(method), new Vector(Arrays.asList(args)));
+            return client.execute(serviceObject + "." + methodName, new Vector(Arrays.asList(convertArguments(args))));
         }
         catch (Exception e)
         {
-            throw new RuntimeException("Could not execute RPC method", e);
+            throw new RuntimeException("Could not execute RPC method " + methodName, e);
         }
     }
     
         }
         return methodName;
     }
+    
+    private Object[] convertArguments(Object[] args)
+    {
+        ArrayList list = new ArrayList();
+        for (Object o : args)
+        {
+            if (o instanceof Collection)
+            {
+                Object[] array = ((Collection)o).toArray();
+                list.add(array);
+            }
+            else
+            {
+                list.add(o);
+            }
+        }
+        return list.toArray();
+    }
 }