Author: cutting Date: Mon Jan 9 13:50:48 2006 New Revision: 367406 URL: http://svn.apache.org/viewcvs?rev=367406&view=rev Log: Fix parallel RPC calls to work correctly with methods that return void.
Modified: lucene/nutch/trunk/src/java/org/apache/nutch/ipc/RPC.java lucene/nutch/trunk/src/test/org/apache/nutch/ipc/TestRPC.java Modified: lucene/nutch/trunk/src/java/org/apache/nutch/ipc/RPC.java URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/src/java/org/apache/nutch/ipc/RPC.java?rev=367406&r1=367405&r2=367406&view=diff ============================================================================== --- lucene/nutch/trunk/src/java/org/apache/nutch/ipc/RPC.java (original) +++ lucene/nutch/trunk/src/java/org/apache/nutch/ipc/RPC.java Mon Jan 9 13:50:48 2006 @@ -149,6 +149,10 @@ Writable[] wrappedValues = CLIENT.call(invocations, addrs); + if (method.getReturnType() == Void.TYPE) { + return null; + } + Object[] values = (Object[])Array.newInstance(method.getReturnType(),wrappedValues.length); for (int i = 0; i < values.length; i++) Modified: lucene/nutch/trunk/src/test/org/apache/nutch/ipc/TestRPC.java URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/src/test/org/apache/nutch/ipc/TestRPC.java?rev=367406&r1=367405&r2=367406&view=diff ============================================================================== --- lucene/nutch/trunk/src/test/org/apache/nutch/ipc/TestRPC.java (original) +++ lucene/nutch/trunk/src/test/org/apache/nutch/ipc/TestRPC.java Mon Jan 9 13:50:48 2006 @@ -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(); }