From cb7efb79cf63ffbd60b61ce94015e0d8e1d3b61e Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 20 Jun 2023 14:27:36 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../converter/WxPayOrderNotifyResultConverter.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/converter/WxPayOrderNotifyResultConverter.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/converter/WxPayOrderNotifyResultConverter.java index dd6f451d9..0f0135863 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/converter/WxPayOrderNotifyResultConverter.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/converter/WxPayOrderNotifyResultConverter.java @@ -110,8 +110,11 @@ public class WxPayOrderNotifyResultConverter extends AbstractReflectionConverter Object val = context.convertAnother(obj, field.getType()); try { if (val != null) { - //这里加一个看似多余的(String)强转可解决高jdk版本下的编译报错问题,详情见讨论https://github.com/vaadin/framework/issues/10737 - PropertyDescriptor pd = new PropertyDescriptor(field.getName(), obj.getClass()); + /* + 这里加一个看似多余的(String)强转可解决高jdk版本下的编译报错问题, + 详情见讨论https://github.com/vaadin/framework/issues/10737 + */ + PropertyDescriptor pd = new PropertyDescriptor((String) field.getName(), obj.getClass()); pd.getWriteMethod().invoke(obj, val); } } catch (Exception ignored) { @@ -129,9 +132,7 @@ public class WxPayOrderNotifyResultConverter extends AbstractReflectionConverter private WxPayOrderNotifyCoupon getElement(Map coupons, String nodeName) { Integer index = Integer.valueOf(StringUtils.substringAfterLast(nodeName, "_")); - if (coupons.get(index) == null) { - coupons.put(index, new WxPayOrderNotifyCoupon()); - } + coupons.computeIfAbsent(index, k -> new WxPayOrderNotifyCoupon()); return coupons.get(index); }