From 27917f2e86bbd97ee047d69817730a57bdf5ad6b Mon Sep 17 00:00:00 2001 From: Ian Luo Date: Wed, 15 Jun 2016 17:09:37 +0800 Subject: [PATCH] =?UTF-8?q?issue#257:=20InvokeTelnetHandler.findMethod=20?= =?UTF-8?q?=E5=85=B3=E4=BA=8E=E9=87=8D=E8=BD=BD=E9=80=BB=E8=BE=91=E6=9C=89?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dubbo/telnet/InvokeTelnetHandler.java | 15 +--- .../protocol/dubbo/support/DemoService.java | 56 +++++++------- .../dubbo/support/DemoServiceImpl.java | 74 ++++++++++--------- 3 files changed, 71 insertions(+), 74 deletions(-) diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java index 4bd16895815..dd78525aae0 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java @@ -116,21 +116,12 @@ public String telnet(Channel channel, String message) { private static Method findMethod(Exporter exporter, String method, List args) { Invoker invoker = exporter.getInvoker(); Method[] methods = invoker.getInterface().getMethods(); - Method invokeMethod = null; for (Method m : methods) { - if (m.getName().equals(method) && m.getParameterTypes().length == args.size()) { - if (invokeMethod != null) { // 重载 - if (isMatch(invokeMethod.getParameterTypes(), args)) { - invokeMethod = m; - break; - } - } else { - invokeMethod = m; - } - invoker = exporter.getInvoker(); + if (m.getName().equals(method) && isMatch(m.getParameterTypes(), args)) { + return m; } } - return invokeMethod; + return null; } private static boolean isMatch(Class[] types, List args) { diff --git a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/DemoService.java b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/DemoService.java index 2619e97e02b..7604e7927a9 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/DemoService.java +++ b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/DemoService.java @@ -1,24 +1,24 @@ -/* - * Copyright 1999-2011 Alibaba Group. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +/* + * Copyright 1999-2011 Alibaba Group. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.alibaba.dubbo.rpc.protocol.dubbo.support; - -import java.util.Map; -import java.util.Set; - - + +import java.util.Map; +import java.util.Set; + + /** * TestService @@ -26,12 +26,14 @@ public interface DemoService { - void sayHello(String name); - + void sayHello(String name); + Set keys(Map map); String echo(String text); + Map echo(Map map); + long timestamp(); String getThreadName(); @@ -50,10 +52,10 @@ public interface DemoService String get(CustomArgument arg1); - byte getbyte(byte arg); - - void nonSerializedParameter(NonSerialized ns); - - NonSerialized returnNonSerialized(); + byte getbyte(byte arg); + + void nonSerializedParameter(NonSerialized ns); + + NonSerialized returnNonSerialized(); } \ No newline at end of file diff --git a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/DemoServiceImpl.java b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/DemoServiceImpl.java index 9eef1dfb7af..f619466945f 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/DemoServiceImpl.java +++ b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/DemoServiceImpl.java @@ -1,24 +1,24 @@ -/* - * Copyright 1999-2011 Alibaba Group. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +/* + * Copyright 1999-2011 Alibaba Group. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.alibaba.dubbo.rpc.protocol.dubbo.support; - -import java.util.Map; -import java.util.Set; - -import com.alibaba.dubbo.rpc.RpcContext; + +import java.util.Map; +import java.util.Set; + +import com.alibaba.dubbo.rpc.RpcContext; /** * DemoServiceImpl @@ -40,6 +40,10 @@ public String echo(String text) return text; } + public Map echo(Map map) { + return map; + } + public long timestamp() { return System.currentTimeMillis(); } @@ -91,20 +95,20 @@ public String get(CustomArgument arg1){ public byte getbyte(byte arg) { return arg; - } - - public Person gerPerson(Person person) { - return person; - } - - public Set keys(Map map) { - return map == null ? null : map.keySet(); - } - - public void nonSerializedParameter(NonSerialized ns) { - } - - public NonSerialized returnNonSerialized() { - return new NonSerialized(); + } + + public Person gerPerson(Person person) { + return person; + } + + public Set keys(Map map) { + return map == null ? null : map.keySet(); + } + + public void nonSerializedParameter(NonSerialized ns) { + } + + public NonSerialized returnNonSerialized() { + return new NonSerialized(); } } \ No newline at end of file