diff --git a/src/main/java/com/loafle/commons/rpc/protocol/json/JSONRPCClientNotificationCodec.java b/src/main/java/com/loafle/commons/rpc/protocol/json/JSONRPCClientNotificationCodec.java index 8c01e00..173c7fc 100644 --- a/src/main/java/com/loafle/commons/rpc/protocol/json/JSONRPCClientNotificationCodec.java +++ b/src/main/java/com/loafle/commons/rpc/protocol/json/JSONRPCClientNotificationCodec.java @@ -52,15 +52,16 @@ public class JSONRPCClientNotificationCodec implements RPCClientNotificationCode Type paramType = paramTypes[i]; String param = this.notification.params.get(i); - JavaType targetType = objectMapper.getTypeFactory().constructType(paramType); - if (!Primitives.isPrimitive(paramType) && !paramType.getTypeName().equals(String.class.getName())) { - try { + try { + JavaType targetType = objectMapper.getTypeFactory().constructType(paramType); + if (!Primitives.isPrimitive(paramType) && !paramType.getTypeName().equals(String.class.getName())) { result[i] = objectMapper.readValue(param, targetType); - } catch (IOException e) { - throw new IllegalArgumentException(); + } else { + result[i] = objectMapper.convertValue(param, targetType); } + } catch (IOException e) { + throw new IllegalArgumentException(); } - result[i] = objectMapper.convertValue(param, targetType); } return result;