Skip to content

Commit 27917f2

Browse files
committed
issue#257: InvokeTelnetHandler.findMethod 关于重载逻辑有问题
1 parent c60a823 commit 27917f2

File tree

3 files changed

+71
-74
lines changed

3 files changed

+71
-74
lines changed

dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,12 @@ public String telnet(Channel channel, String message) {
116116
private static Method findMethod(Exporter<?> exporter, String method, List<Object> args) {
117117
Invoker<?> invoker = exporter.getInvoker();
118118
Method[] methods = invoker.getInterface().getMethods();
119-
Method invokeMethod = null;
120119
for (Method m : methods) {
121-
if (m.getName().equals(method) && m.getParameterTypes().length == args.size()) {
122-
if (invokeMethod != null) { // 重载
123-
if (isMatch(invokeMethod.getParameterTypes(), args)) {
124-
invokeMethod = m;
125-
break;
126-
}
127-
} else {
128-
invokeMethod = m;
129-
}
130-
invoker = exporter.getInvoker();
120+
if (m.getName().equals(method) && isMatch(m.getParameterTypes(), args)) {
121+
return m;
131122
}
132123
}
133-
return invokeMethod;
124+
return null;
134125
}
135126

136127
private static boolean isMatch(Class<?>[] types, List<Object> args) {
Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,39 @@
1-
/*
2-
* Copyright 1999-2011 Alibaba Group.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
1+
/*
2+
* Copyright 1999-2011 Alibaba Group.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
1616
package com.alibaba.dubbo.rpc.protocol.dubbo.support;
17-
18-
import java.util.Map;
19-
import java.util.Set;
20-
21-
17+
18+
import java.util.Map;
19+
import java.util.Set;
20+
21+
2222

2323
/**
2424
* <code>TestService</code>
2525
*/
2626

2727
public interface DemoService
2828
{
29-
void sayHello(String name);
30-
29+
void sayHello(String name);
30+
3131
Set<String> keys(Map<String, String> map);
3232

3333
String echo(String text);
3434

35+
Map echo(Map map);
36+
3537
long timestamp();
3638

3739
String getThreadName();
@@ -50,10 +52,10 @@ public interface DemoService
5052

5153
String get(CustomArgument arg1);
5254

53-
byte getbyte(byte arg);
54-
55-
void nonSerializedParameter(NonSerialized ns);
56-
57-
NonSerialized returnNonSerialized();
55+
byte getbyte(byte arg);
56+
57+
void nonSerializedParameter(NonSerialized ns);
58+
59+
NonSerialized returnNonSerialized();
5860

5961
}

dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/DemoServiceImpl.java

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
/*
2-
* Copyright 1999-2011 Alibaba Group.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
1+
/*
2+
* Copyright 1999-2011 Alibaba Group.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
1616
package com.alibaba.dubbo.rpc.protocol.dubbo.support;
17-
18-
import java.util.Map;
19-
import java.util.Set;
20-
21-
import com.alibaba.dubbo.rpc.RpcContext;
17+
18+
import java.util.Map;
19+
import java.util.Set;
20+
21+
import com.alibaba.dubbo.rpc.RpcContext;
2222

2323
/**
2424
* DemoServiceImpl
@@ -40,6 +40,10 @@ public String echo(String text)
4040
return text;
4141
}
4242

43+
public Map echo(Map map) {
44+
return map;
45+
}
46+
4347
public long timestamp() {
4448
return System.currentTimeMillis();
4549
}
@@ -91,20 +95,20 @@ public String get(CustomArgument arg1){
9195

9296
public byte getbyte(byte arg) {
9397
return arg;
94-
}
95-
96-
public Person gerPerson(Person person) {
97-
return person;
98-
}
99-
100-
public Set<String> keys(Map<String, String> map) {
101-
return map == null ? null : map.keySet();
102-
}
103-
104-
public void nonSerializedParameter(NonSerialized ns) {
105-
}
106-
107-
public NonSerialized returnNonSerialized() {
108-
return new NonSerialized();
98+
}
99+
100+
public Person gerPerson(Person person) {
101+
return person;
102+
}
103+
104+
public Set<String> keys(Map<String, String> map) {
105+
return map == null ? null : map.keySet();
106+
}
107+
108+
public void nonSerializedParameter(NonSerialized ns) {
109+
}
110+
111+
public NonSerialized returnNonSerialized() {
112+
return new NonSerialized();
109113
}
110114
}

0 commit comments

Comments
 (0)