Skip to content

Commit

Permalink
issue#257: InvokeTelnetHandler.findMethod 关于重载逻辑有问题
Browse files Browse the repository at this point in the history
  • Loading branch information
beiwei30 committed Jun 15, 2016
1 parent c60a823 commit 27917f2
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,12 @@ public String telnet(Channel channel, String message) {
private static Method findMethod(Exporter<?> exporter, String method, List<Object> 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<Object> args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
/*
* 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;



/**
* <code>TestService</code>
*/

public interface DemoService
{
void sayHello(String name);

void sayHello(String name);

Set<String> keys(Map<String, String> map);

String echo(String text);

Map echo(Map map);

long timestamp();

String getThreadName();
Expand All @@ -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();

}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -40,6 +40,10 @@ public String echo(String text)
return text;
}

public Map echo(Map map) {
return map;
}

public long timestamp() {
return System.currentTimeMillis();
}
Expand Down Expand Up @@ -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<String> keys(Map<String, String> 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<String> keys(Map<String, String> map) {
return map == null ? null : map.keySet();
}

public void nonSerializedParameter(NonSerialized ns) {
}

public NonSerialized returnNonSerialized() {
return new NonSerialized();
}
}

0 comments on commit 27917f2

Please sign in to comment.