From b17d06cc12b4b5bdf4b6eadb2c9a782599d59253 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 21 Dec 2018 11:32:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/chanjar/weixin/cp/bean/WxCpXmlMessage.java | 3 ++- .../me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java | 3 ++- .../chanjar/weixin/open/bean/message/WxOpenXmlMessage.java | 3 ++- .../binarywang/wxpay/bean/result/BaseWxPayResult.java | 7 ++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlMessage.java index cab4970b..3fc2137f 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlMessage.java @@ -3,6 +3,7 @@ package me.chanjar.weixin.cp.bean; import java.io.IOException; import java.io.InputStream; import java.io.Serializable; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; @@ -369,7 +370,7 @@ public class WxCpXmlMessage implements Serializable { public static WxCpXmlMessage fromEncryptedXml(InputStream is, WxCpConfigStorage wxCpConfigStorage, String timestamp, String nonce, String msgSignature) { try { - return fromEncryptedXml(IOUtils.toString(is, "UTF-8"), wxCpConfigStorage, timestamp, nonce, msgSignature); + return fromEncryptedXml(IOUtils.toString(is, StandardCharsets.UTF_8), wxCpConfigStorage, timestamp, nonce, msgSignature); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java index 3ec7a966..368f70e3 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java @@ -3,6 +3,7 @@ package me.chanjar.weixin.mp.bean.message; import java.io.IOException; import java.io.InputStream; import java.io.Serializable; +import java.nio.charset.StandardCharsets; import java.util.Map; import org.apache.commons.io.IOUtils; @@ -662,7 +663,7 @@ public class WxMpXmlMessage implements Serializable { public static WxMpXmlMessage fromEncryptedXml(InputStream is, WxMpConfigStorage wxMpConfigStorage, String timestamp, String nonce, String msgSignature) { try { - return fromEncryptedXml(IOUtils.toString(is, "UTF-8"), wxMpConfigStorage, timestamp, nonce, msgSignature); + return fromEncryptedXml(IOUtils.toString(is, StandardCharsets.UTF_8), wxMpConfigStorage, timestamp, nonce, msgSignature); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java index f3819452..a6ba9945 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java @@ -3,6 +3,7 @@ package me.chanjar.weixin.open.bean.message; import java.io.IOException; import java.io.InputStream; import java.io.Serializable; +import java.nio.charset.StandardCharsets; import org.apache.commons.io.IOUtils; @@ -99,7 +100,7 @@ public class WxOpenXmlMessage implements Serializable { public static WxOpenXmlMessage fromEncryptedXml(InputStream is, WxOpenConfigStorage wxOpenConfigStorage, String timestamp, String nonce, String msgSignature) { try { - return fromEncryptedXml(IOUtils.toString(is, "UTF-8"), + return fromEncryptedXml(IOUtils.toString(is, StandardCharsets.UTF_8), wxOpenConfigStorage, timestamp, nonce, msgSignature); } catch (IOException e) { throw new RuntimeException(e); diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/BaseWxPayResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/BaseWxPayResult.java index 6dec4863..b0233ded 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/BaseWxPayResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/BaseWxPayResult.java @@ -1,14 +1,12 @@ package com.github.binarywang.wxpay.bean.result; import java.io.ByteArrayInputStream; -import java.io.IOException; import java.io.Serializable; import java.math.BigDecimal; import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; @@ -18,7 +16,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; import com.github.binarywang.wxpay.constant.WxPayConstants; import com.github.binarywang.wxpay.exception.WxPayException; @@ -195,8 +192,8 @@ public abstract class BaseWxPayResult implements Serializable { this.xmlDoc = factory.newDocumentBuilder() .parse(new ByteArrayInputStream(this.xmlString.getBytes(StandardCharsets.UTF_8))); return xmlDoc; - } catch (SAXException | IOException | ParserConfigurationException e) { - throw new RuntimeException("非法的xml文本内容:" + this.xmlString); + } catch (Exception e) { + throw new RuntimeException("非法的xml文本内容:\n" + this.xmlString, e); } }