Hi,
yes I can but I already have a patch that at least solve me problem. :-)
What you think about this solution?
If you like me and it make sense I can file a bug report with test
and patch.
Index: src/java/org/apache/hadoop/ipc/RPC.java
===================================================================
--- src/java/org/apache/hadoop/ipc/RPC.java (revision 396952)
+++ src/java/org/apache/hadoop/ipc/RPC.java (working copy)
@@ -233,9 +233,7 @@
Invocation call = (Invocation)param;
if (verbose) log("Call: " + call);
- Method method =
- implementation.getMethod(call.getMethodName(),
- call.getParameterClasses());
+ Method method = findMethod(call);
Object value = method.invoke(instance, call.getParameters());
if (verbose) log("Return: "+value);
@@ -257,6 +255,30 @@
throw ioe;
}
}
+
+ private Method findMethod(Invocation call) throws
NoSuchMethodException {
+ Method[] methods = implementation.getMethods();
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].getName().equals(call.getMethodName())) {
+ Class[] parameterTypes = methods[i].getParameterTypes();
+ Class[] parameterClasses = call.getParameterClasses();
+ if (parameterTypes.length == parameterClasses.length) {
+ boolean match = true;
+ for (int j = 0; j < parameterTypes.length; j++) {
+ if (!parameterTypes[j].isAssignableFrom
(parameterClasses[j])) {
+ match = false;
+ break;
+ }
+ }
+ if (match) {
+ return methods[i];
+ }
+ }
+ }
+ }
+ throw new NoSuchMethodException();
+ }
+
}
private static void log(String value) {
On 26.04.2006, at 00:20, Doug Cutting wrote:
Can you supply a simple test case?
Thanks,
Doug
Stefan Groschupf wrote:
Hi,
I would love to use the RPC.getProxy but my Server uses Interfaces
as parameter.
When I now invoke my proxy client with concrete implementation
the server throws a java.io.IOException:
java.lang.NoSuchMethodException,
at java.lang.Class.getMethod(Class.java:1581)
at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:237)
at org.apache.hadoop.ipc.Server$Handler.run(Server.java:218)
since call.getParameterClasses() returns the concrete classes and
not the interfaces the classes implements.
Any idea how to workaround the problem?
Thanks.
Stefan