You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nutch.apache.org by Stefan Groschupf <sg...@media-style.com> on 2005/12/06 18:13:46 UTC
RCP known limitation or bug?
Hi,
I never used the RCP that intensive so I was surprised to found this
limitation.
Is it known that the RCP.call method can only call methods that have
a return type?
RCP.java line 152
Object[] values =
(Object[])Array.newInstance(method.getReturnType
(),wrappedValues.length);
Throws in Array IlleagalArgumentException since the return type is
null.
May it would be better to add a statement to the java doc (or did I
missed this statement) or may better to send the NullWritable as
placeholder back?
In case this is a bug, should I commit a patch for this 3 lines if
than else or can one with write rights just fix this?
Stefan
Re: RCP known limitation or bug?
Posted by Stefan Groschupf <sg...@media-style.com>.
Sure...
the test case:
###########
package org.apache.nutch.ipc;
import java.lang.reflect.Method;
import java.net.InetSocketAddress;
import junit.framework.TestCase;
public class TestMultiCall extends TestCase {
private Server fServer;
public TestMultiCall() {
fServer = RPC.getServer(new Sample(), 2323);
}
public void testWithtReturn() throws Exception {
Method method = Sample.class.getMethod("helloWorld1", new
Class[0]);
Object[][] params = new Object[0][];
InetSocketAddress[] addrs = new InetSocketAddress[] { new
InetSocketAddress("127.0.0.1", 2323) };
Object[] objects = RPC.call(method, params, addrs);
}
public void testWithoutReturn() throws Exception {
Method method = Sample.class.getMethod("helloWorld2", new
Class[0]);
Object[][] params = new Object[0][];
InetSocketAddress[] addrs = new InetSocketAddress[] { new
InetSocketAddress("127.0.0.1", 2323) };
Object[] objects = RPC.call(method, params, addrs);
}
protected void finalize() throws Throwable {
fServer.stop();
}
class Sample {
public String helloWorld1() {
System.out.println("hello world...");
return "foo";
}
public void helloWorld2() {
System.out.println("hello world...");
}
}
}
##########
the stack trace:
java.lang.IllegalArgumentException
at java.lang.reflect.Array.newArray(Native Method)
at java.lang.reflect.Array.newInstance(Array.java:52)
at org.apache.nutch.ipc.RPC.call(RPC.java:153)
at org.apache.nutch.ipc.TestMultiCall.testWithoutReturn
(TestMultiCall.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run
(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main
(RemoteTestRunner.java:196)
The nutch test suite pass without any problem on my system.
java 1.4.2-54,osx10.4.4, I tested it on several boxes but all of them
used the appleJvm, may sun's jvm accepts Array.newInstance(null ,0)?
Stefan
Am 07.12.2005 um 20:29 schrieb Doug Cutting:
> This should work. TestRPC.java has a case which returns void
> (ping). Can you send a simple test case that fails?
>
> Doug
>
> Stefan Groschupf wrote:
>> Hi,
>> I never used the RCP that intensive so I was surprised to found
>> this limitation.
>> Is it known that the RCP.call method can only call methods that
>> have a return type?
>> RCP.java line 152
>> Object[] values =
>> (Object[])Array.newInstance(method.getReturnType
>> (),wrappedValues.length);
>> Throws in Array IlleagalArgumentException since the return type
>> is null.
>> May it would be better to add a statement to the java doc (or did
>> I missed this statement) or may better to send the NullWritable
>> as placeholder back?
>> In case this is a bug, should I commit a patch for this 3 lines
>> if than else or can one with write rights just fix this?
>> Stefan
>
---------------------------------------------------------------
company: http://www.media-style.com
forum: http://www.text-mining.org
blog: http://www.find23.net
Re: RCP known limitation or bug?
Posted by Doug Cutting <cu...@nutch.org>.
This should work. TestRPC.java has a case which returns void (ping).
Can you send a simple test case that fails?
Doug
Stefan Groschupf wrote:
> Hi,
> I never used the RCP that intensive so I was surprised to found this
> limitation.
> Is it known that the RCP.call method can only call methods that have a
> return type?
> RCP.java line 152
> Object[] values =
> (Object[])Array.newInstance(method.getReturnType
> (),wrappedValues.length);
> Throws in Array IlleagalArgumentException since the return type is null.
>
> May it would be better to add a statement to the java doc (or did I
> missed this statement) or may better to send the NullWritable as
> placeholder back?
>
> In case this is a bug, should I commit a patch for this 3 lines if than
> else or can one with write rights just fix this?
>
> Stefan