-
Notifications
You must be signed in to change notification settings - Fork 26.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix 3105 , make invoke command with Json string parameter without "cl…
…ass" key
- Loading branch information
Showing
3 changed files
with
41 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,8 @@ | |
*/ | ||
package org.apache.dubbo.rpc.protocol.dubbo.telnet; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.JSONObject; | ||
import org.apache.dubbo.common.extension.Activate; | ||
import org.apache.dubbo.common.utils.ReflectUtils; | ||
import org.apache.dubbo.common.utils.StringUtils; | ||
|
@@ -27,14 +29,10 @@ | |
import org.apache.dubbo.rpc.model.ProviderMethodModel; | ||
import org.apache.dubbo.rpc.model.ProviderModel; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.JSONObject; | ||
|
||
import java.lang.reflect.Method; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.apache.dubbo.common.utils.PojoUtils.realize; | ||
import static org.apache.dubbo.rpc.RpcContext.getContext; | ||
|
@@ -50,19 +48,19 @@ private static Method findMethod(List<ProviderMethodModel> methods, String metho | |
Class<?>[] paramTypes) { | ||
for (ProviderMethodModel model : methods) { | ||
Method m = model.getMethod(); | ||
if (isMatch(m, args, paramTypes,method)) { | ||
if (isMatch(m, args, paramTypes, method)) { | ||
return m; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
private static boolean isMatch(Method method,List<Object> args, Class<?>[] paramClasses,String lookupMethodName) { | ||
if(!method.getName().equals(lookupMethodName)) { | ||
private static boolean isMatch(Method method, List<Object> args, Class<?>[] paramClasses, String lookupMethodName) { | ||
if (!method.getName().equals(lookupMethodName)) { | ||
return false; | ||
} | ||
|
||
Class<?> types[]=method.getParameterTypes(); | ||
Class<?> types[] = method.getParameterTypes(); | ||
if (types.length != args.size()) { | ||
return false; | ||
} | ||
|
@@ -99,13 +97,10 @@ private static boolean isMatch(Method method,List<Object> args, Class<?>[] param | |
if (!ReflectUtils.isCompatible(type, arg)) { | ||
return false; | ||
} | ||
} else if (arg instanceof Map) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
LiZhenNet
Author
Contributor
|
||
String name = (String) ((Map<?, ?>) arg).get("class"); | ||
Class<?> cls = arg.getClass(); | ||
if (name != null && name.length() > 0) { | ||
cls = ReflectUtils.forName(name); | ||
} | ||
if (!type.isAssignableFrom(cls)) { | ||
} else if (arg instanceof JSONObject) { | ||
try { | ||
((JSONObject) arg).toJavaObject(type); | ||
} catch (Exception ex) { | ||
return false; | ||
} | ||
} else if (arg instanceof Collection) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I think the original code should not be deleted, the code should be added in advance.
class
field is still valid, so it should not be deleted.class
field more efficiently, avoiding aJsonObject.toJavaObject
invoke