Re: [bug?] PRC called emthod require parameter

2006-01-06 Thread Doug Cutting

Stefan Groschupf wrote:
Different parameters are sent to each address.  So params.length  
should equal addresses.length, and if params.length==0 then  
addresses.length==0 and there's no call to be made.  Make sense?   It 
might be clearer if the test were changed to addresses.length==0.


Yes, this would be better, since it would than be  possible to call a  
set of addresses but not send any parameter (e.g.  'reboot()').

Should I open a jira issue for that?


No, I just made the change.

Also what happens with the other rpc bug? I submitted a test that  
reproduces the error as you had requested. I can fix this,  ... it is  
just one line


What bug was that?  What is your one-line fix?

Doug


Re: [bug?] PRC called emthod require parameter

2006-01-06 Thread Stefan Groschupf

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];

Re: [bug?] PRC called emthod require parameter

2006-01-06 Thread Doug Cutting

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();
   }


Re: [bug?] PRC called emthod require parameter

2006-01-03 Thread Stefan Groschupf
Different parameters are sent to each address.  So params.length  
should equal addresses.length, and if params.length==0 then  
addresses.length==0 and there's no call to be made.  Make sense?   
It might be clearer if the test were changed to addresses.length==0.


Yes, this would be better, since it would than be  possible to call a  
set of addresses but not send any parameter (e.g.  'reboot()').

Should I open a jira issue for that?
Also what happens with the other rpc bug? I submitted a test that  
reproduces the error as you had requested. I can fix this,  ... it is  
just one line


Thanks.
Stefan 


Re: [bug?] PRC called emthod require parameter

2006-01-02 Thread Doug Cutting

Stefan Groschupf wrote:

I also note this line in client.java
public Writable[] call(Writable[] params, InetSocketAddress[] addresses)
throws IOException {
if (params.length == 0) return new Writable[0];

Do I understand it correct that in case the remote method does not  need 
any parameter no remote call is done?


Different parameters are sent to each address.  So params.length should 
equal addresses.length, and if params.length==0 then addresses.length==0 
and there's no call to be made.  Make sense?  It might be clearer if the 
test were changed to addresses.length==0.


Doug