Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize generic filter #8067

Merged
merged 1 commit into from Jun 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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