From 1ade0072501a4c602260bc0ab53efe8ec54a60fa Mon Sep 17 00:00:00 2001 From: Daniel Qian Date: Fri, 10 Jul 2015 13:57:40 +0800 Subject: [PATCH 1/6] upgrade to 1.1.7 --- pom.xml | 2 +- weixin-java-common/pom.xml | 2 +- weixin-java-cp/pom.xml | 2 +- weixin-java-mp/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 1eb48642..cc16cf7d 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 me.chanjar weixin-java-parent - 1.1.7-SNAPSHOT + 1.1.7 pom WeiXin Java Tools - Parent 微信公众号、企业号上级POM diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml index 17b8bc90..2ca6bba1 100644 --- a/weixin-java-common/pom.xml +++ b/weixin-java-common/pom.xml @@ -6,7 +6,7 @@ me.chanjar weixin-java-parent - 1.1.7-SNAPSHOT + 1.1.7 weixin-java-common diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml index a67ddaf7..74a784b6 100644 --- a/weixin-java-cp/pom.xml +++ b/weixin-java-cp/pom.xml @@ -6,7 +6,7 @@ me.chanjar weixin-java-parent - 1.1.7-SNAPSHOT + 1.1.7 weixin-java-cp diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml index 7ff9f237..7f733dbb 100644 --- a/weixin-java-mp/pom.xml +++ b/weixin-java-mp/pom.xml @@ -6,7 +6,7 @@ me.chanjar weixin-java-parent - 1.1.7-SNAPSHOT + 1.1.7 weixin-java-mp WeiXin Java Tools - MP From 6239abcbcc7ca2e9c73e8440f3110f3834c47fff Mon Sep 17 00:00:00 2001 From: Daniel Qian Date: Fri, 10 Jul 2015 13:59:28 +0800 Subject: [PATCH 2/6] update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 881af49c..a1da143a 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ weixin-java-tools me.chanjar weixin-java-cp - 1.1.6 + 1.1.7 ``` From f30211ce987f298fcfc100255caa5402283600aa Mon Sep 17 00:00:00 2001 From: Daniel Qian Date: Fri, 10 Jul 2015 14:03:37 +0800 Subject: [PATCH 3/6] upgrade version 1.1.8-SNAPSHOT --- README.md | 4 ++-- pom.xml | 2 +- weixin-java-common/pom.xml | 2 +- weixin-java-cp/pom.xml | 2 +- weixin-java-mp/pom.xml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a1da143a..26cb3922 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ weixin-java-tools me.chanjar weixin-java-mp - 1.1.6 + 1.1.8 ``` @@ -27,7 +27,7 @@ weixin-java-tools me.chanjar weixin-java-cp - 1.1.7 + 1.1.8 ``` diff --git a/pom.xml b/pom.xml index cc16cf7d..e49b5edc 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 me.chanjar weixin-java-parent - 1.1.7 + 1.1.8-SNAPSHOT pom WeiXin Java Tools - Parent 微信公众号、企业号上级POM diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml index 2ca6bba1..85b1d63b 100644 --- a/weixin-java-common/pom.xml +++ b/weixin-java-common/pom.xml @@ -6,7 +6,7 @@ me.chanjar weixin-java-parent - 1.1.7 + 1.1.8-SNAPSHOT weixin-java-common diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml index 74a784b6..95f8972b 100644 --- a/weixin-java-cp/pom.xml +++ b/weixin-java-cp/pom.xml @@ -6,7 +6,7 @@ me.chanjar weixin-java-parent - 1.1.7 + 1.1.8-SNAPSHOT weixin-java-cp diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml index 7f733dbb..9fd2c8fd 100644 --- a/weixin-java-mp/pom.xml +++ b/weixin-java-mp/pom.xml @@ -6,7 +6,7 @@ me.chanjar weixin-java-parent - 1.1.7 + 1.1.8-SNAPSHOT weixin-java-mp WeiXin Java Tools - MP From 4bee1ba2eb0573798d6349fd4132620d531fb161 Mon Sep 17 00:00:00 2001 From: Daniel Qian Date: Mon, 13 Jul 2015 12:32:00 +0800 Subject: [PATCH 4/6] =?UTF-8?q?#165=20MediaDownloadRequestExecutor?= =?UTF-8?q?=E5=87=BA=E9=94=99=E5=90=8E=E5=B0=B1=E6=B2=A1=E6=9C=89=E5=8A=9E?= =?UTF-8?q?=E6=B3=95=E4=B8=8B=E8=BD=BD=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../http/MediaDownloadRequestExecutor.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java index 32a7c917..fff109bb 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java @@ -63,16 +63,23 @@ public class MediaDownloadRequestExecutor implements RequestExecutor Date: Mon, 13 Jul 2015 17:25:46 +0800 Subject: [PATCH 5/6] #165 #167 --- .../http/MediaDownloadRequestExecutor.java | 26 ++++++++----------- .../util/http/MediaUploadRequestExecutor.java | 13 +++++----- .../util/http/SimpleGetRequestExecutor.java | 13 +++++----- .../util/http/SimplePostRequestExecutor.java | 13 +++++----- .../weixin/cp/api/WxCpServiceImpl.java | 6 +++-- .../mp/util/http/QrCodeRequestExecutor.java | 25 +++++++++--------- 6 files changed, 49 insertions(+), 47 deletions(-) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java index fff109bb..f9e3a25f 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java @@ -53,19 +53,17 @@ public class MediaDownloadRequestExecutor implements RequestExecutor 0) { - // 下载媒体文件出错 - if (ContentType.TEXT_PLAIN.getMimeType().equals(contentTypeHeader[0].getValue())) { - String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); - throw new WxErrorException(WxError.fromJson(responseContent)); + Header[] contentTypeHeader = response.getHeaders("Content-Type"); + if (contentTypeHeader != null && contentTypeHeader.length > 0) { + // 下载媒体文件出错 + if (ContentType.TEXT_PLAIN.getMimeType().equals(contentTypeHeader[0].getValue())) { + String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); + throw new WxErrorException(WxError.fromJson(responseContent)); + } } - } - InputStream inputStream = null; - try { - inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response); + InputStream inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response); // 视频文件不支持下载 String fileName = getFileName(response); @@ -75,11 +73,9 @@ public class MediaDownloadRequestExecutor implements RequestExecutor httpGet.setConfig(config); } - CloseableHttpResponse response = httpclient.execute(httpGet); - String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); - WxError error = WxError.fromJson(responseContent); - if (error.getErrorCode() != 0) { - throw new WxErrorException(error); + try (CloseableHttpResponse response = httpclient.execute(httpGet)) { + String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); + WxError error = WxError.fromJson(responseContent); + if (error.getErrorCode() != 0) { + throw new WxErrorException(error); + } + return responseContent; } - return responseContent; } } diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/SimplePostRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/SimplePostRequestExecutor.java index d50fe251..1ab1ad7e 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/SimplePostRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/SimplePostRequestExecutor.java @@ -40,13 +40,14 @@ public class SimplePostRequestExecutor implements RequestExecutor 0) { - // 出错 - if (ContentType.TEXT_PLAIN.getMimeType().equals(contentTypeHeader[0].getValue())) { - String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); - throw new WxErrorException(WxError.fromJson(responseContent)); + try (CloseableHttpResponse response = httpclient.execute(httpGet)) { + Header[] contentTypeHeader = response.getHeaders("Content-Type"); + if (contentTypeHeader != null && contentTypeHeader.length > 0) { + // 出错 + if (ContentType.TEXT_PLAIN.getMimeType().equals(contentTypeHeader[0].getValue())) { + String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); + throw new WxErrorException(WxError.fromJson(responseContent)); + } } + InputStream inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response); + + File localFile = FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), "jpg"); + return localFile; } - InputStream inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response); - - File localFile = FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), "jpg"); - return localFile; + } } From 8d950286588c2784b75f88a72132ace4ef987c4d Mon Sep 17 00:00:00 2001 From: Daniel Qian Date: Mon, 13 Jul 2015 17:28:27 +0800 Subject: [PATCH 6/6] =?UTF-8?q?fix:=20IDEA=20=E5=AF=BC=E5=85=A5=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E6=80=BB=E6=98=AF=E4=BC=9A=E5=B0=86=E7=BC=96?= =?UTF-8?q?=E8=AF=91level=E5=8F=98=E6=88=905.0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pom.xml b/pom.xml index e49b5edc..a20bb619 100644 --- a/pom.xml +++ b/pom.xml @@ -225,6 +225,16 @@ deploy + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.7 + 1.7 + UTF-8 + +