Okay, here's my patch attached.
We don't need an all-new unit test file, when just a few lines are
needed there.
Does this look right to you?
Doug
Stefan Groschupf wrote:
What bug was that? What is your one-line fix?
http://www.nabble.com/RCP-known-limitation-or-bug--t688207.html
something like:
Object[] values;
method.getReturnType()!=null ? values = (Object[])Array.newInstance
(method.getReturnType(),wrappedValues.length) : values = new Object[0];
Index: src/java/org/apache/nutch/ipc/RPC.java
===================================================================
--- src/java/org/apache/nutch/ipc/RPC.java (revision 366552)
+++ src/java/org/apache/nutch/ipc/RPC.java (working copy)
@@ -149,8 +149,14 @@
Writable[] wrappedValues = CLIENT.call(invocations, addrs);
+ Class returnType = method.getReturnType();
+ if (returnType == Void.TYPE) {
+ return null;
+ }
+
Object[] values =
- (Object[])Array.newInstance(method.getReturnType(),wrappedValues.length);
+ (Object[])Array.newInstance(returnType, wrappedValues.length);
+
for (int i = 0; i < values.length; i++)
if (wrappedValues[i] != null)
values[i] = ((ObjectWritable)wrappedValues[i]).get();
Index: src/test/org/apache/nutch/ipc/TestRPC.java
===================================================================
--- src/test/org/apache/nutch/ipc/TestRPC.java (revision 366552)
+++ src/test/org/apache/nutch/ipc/TestRPC.java (working copy)
@@ -110,13 +110,17 @@
}
assertTrue(caught);
- // try a multi-call
- Method method =
+ // try some multi-calls
+ Method echo =
TestProtocol.class.getMethod("echo", new Class[] { String.class });
- String[] values = (String[])RPC.call(method, new String[][]{{"a"},{"b"}},
+ String[] strings = (String[])RPC.call(echo, new String[][]{{"a"},{"b"}},
new InetSocketAddress[] {addr, addr});
- assertTrue(Arrays.equals(values, new String[]{"a","b"}));
+ assertTrue(Arrays.equals(strings, new String[]{"a","b"}));
+ Method ping = TestProtocol.class.getMethod("ping", new Class[] {});
+ Object[] voids = (Object[])RPC.call(ping, new Object[][]{{},{}},
+ new InetSocketAddress[] {addr, addr});
+ assertEquals(voids, null);
server.stop();
}