Aias00 commented on code in PR #7146:
URL: https://github.com/apache/shenyu/pull/7146#discussion_r4059881802


##########
shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-grpc/src/main/java/org/apache/shenyu/plugin/grpc/GrpcPlugin.java:
##########
@@ -104,7 +104,10 @@ protected Mono<Void> doExecute(final ServerWebExchange 
exchange, final ShenyuPlu
                         .map(InetAddress::getHostAddress)
                         .orElse(StringUtils.EMPTY)).attach();
 
-        GrpcExtInfo extInfo = 
GsonUtils.getGson().fromJson(metaData.getRpcExt(), GrpcExtInfo.class);
+        GrpcExtInfo extInfo = StringUtils.isBlank(metaData.getRpcExt())

Review Comment:
   Suggestion (non-blocking): the guard covers the case where Gson returns a 
null object, but not the case where individual fields end up null. If `rpcExt` 
contains `"methodType": null`, or an enum name Gson cannot resolve, the field 
is left null and `ShenyuGrpcClient#invoke` still NPEs on `switch (methodType)` 
(same for `JsonMessage#getMethodType`).
   
   A small normalisation after parsing would close the same class of bug 
completely - e.g. after building `extInfo`, `if 
(Objects.isNull(extInfo.getMethodType())) { 
extInfo.setMethodType(MethodDescriptor.MethodType.UNARY); }` with a warn log.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to