Skip to content

Commit

Permalink
This is a combination of 2 commits.
Browse files Browse the repository at this point in the history
optimize generic filter
  • Loading branch information
goodjava committed Jun 16, 2021
1 parent 8892a36 commit e115c22
Showing 1 changed file with 6 additions and 1 deletion.
Expand Up @@ -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))
Expand Down Expand Up @@ -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("When using GSON to deserialize generic dubbo request arguments, the arguments must be of type String");
}
String str = args[i].toString();
Type type = TypeToken.get(types[i]).getType();
try {
Expand Down

0 comments on commit e115c22

Please sign in to comment.