diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java index 831c7a5f72cf..b97c379053a6 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java @@ -65,8 +65,11 @@ */ @Activate(group = CommonConstants.PROVIDER, order = -20000) public class GenericFilter implements Filter, Filter.Listener { + private static final Logger logger = LoggerFactory.getLogger(GenericFilter.class); + private static final Gson gson = new Gson(); + @Override public Result invoke(Invoker invoker, Invocation inv) throws RpcException { if ((inv.getMethodName().equals($INVOKE) || inv.getMethodName().equals($INVOKE_ASYNC)) @@ -190,8 +193,10 @@ public Result invoke(Invoker invoker, Invocation inv) throws RpcException { } private Object[] getGsonGenericArgs(final Object[] args, Type[] types) { - Gson gson = new Gson(); return IntStream.range(0, args.length).mapToObj(i -> { + if (!(args[i] instanceof String)) { + throw new RpcException(String.format("Generic serialization [%s] Json syntax exception thrown when parsing (%s)", GENERIC_SERIALIZATION_GSON, "parameter type must be String")); + } String str = args[i].toString(); Type type = TypeToken.get(types[i]).getType(); try {