Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
1812b23
art:证书类配置读取优化调整
Aug 17, 2020
2b27ee9
new:电商收付通二级商户进件
Aug 17, 2020
a3ec261
Merge branch 'develop' into develop
binarywang Aug 18, 2020
425b082
Merge branch 'master' into develop
binarywang Aug 23, 2020
cee3753
Merge remote-tracking branch 'wechat/develop' into develop
Aug 24, 2020
10e0ca5
art:微信服务商配置优化
Aug 24, 2020
5db9706
new:jsapi合单支付
Aug 24, 2020
e0d87eb
new:合单支付
Aug 26, 2020
6c490e3
:art: #1733 微信支付服务商配置优化,增加服务商合单支付接口
cloudX2019 Aug 29, 2020
84b9b99
Merge remote-tracking branch 'wechat/develop' into develop
Aug 30, 2020
64f7adc
:art: 优化代码
binarywang Aug 30, 2020
7cfabab
:art: 优化重构并统一公众号和小程序的spring boot starter部分配置类和属性
binarywang Aug 30, 2020
c01347c
:art: 优化企业微信消息发送接口代码,引入moco模拟测试组件,方便测试代码
binarywang Aug 30, 2020
53ad42e
:art: #1722 企业微信增加互联企业发送应用消息的接口,并重构消息相关类的包结构
binarywang Aug 30, 2020
541899a
Merge remote-tracking branch 'wechat/develop' into develop
Sep 4, 2020
31ecd4d
:art: 优化代码,使用java8自带的Base64类
binarywang Sep 4, 2020
07352d1
:bug: #1738 修复企业微信创建用户接口自定义字段缺失的问题
binarywang Sep 4, 2020
010b431
:art: 升级依赖的Spring Boot版本为最新,并优化部分代码
binarywang Sep 5, 2020
e04eaf4
:bookmark: 发布 3.9.1.B 测试版本
binarywang Sep 5, 2020
dfec2e3
:art: #1743 企业微信获取客户群详情接口增加unionId属性
borisbao Sep 7, 2020
9f60516
Merge remote-tracking branch 'wechat/develop' into develop
Sep 8, 2020
97409a7
new:电商收付通普通支付
Sep 8, 2020
9359885
:new: #1744 微信支付增加电商收付通-普通支付相关接口
cloudX2019 Sep 9, 2020
f18c62b
new:电商收付通支付回调处理
Sep 10, 2020
b8d9a15
Merge remote-tracking branch 'wechat/develop' into develop
Sep 10, 2020
c8fc670
new:电商收付通支付回调处理
Sep 10, 2020
6927eaa
:new: #1749 微信支付增加电商收付通支付回调处理相关方法
cloudX2019 Sep 10, 2020
0605761
:art: #1752 微信支付电商收付通二级商户进件时店铺信息增加小程序appid字段
f00lish Sep 10, 2020
7bf811a
:art: 优化部分代码
binarywang Sep 10, 2020
4f157b0
Merge remote-tracking branch 'wechat/develop' into develop
Sep 10, 2020
34f0d99
电商收付通支付调整
Sep 11, 2020
efdf64e
:art: 电商收付通支付接口调整
cloudX2019 Sep 11, 2020
c2552de
Merge remote-tracking branch 'wechat/develop' into develop
Sep 11, 2020
19b033c
:art: #1756 解决wx-java-open-spring-boot-starter中Redisson实现缺少database设…
stoneliu-coder Sep 12, 2020
ef0b34b
:art: #1753 小程序直播部分接口代码优化重构,对照官方文档补充新增参数
binarywang Sep 12, 2020
b15142a
:art: #1747 微信支付分回调通知对象类增加缺失参数:回调摘要summary
binarywang Sep 12, 2020
6c31059
:new: #1758 微信支付增加电商收付通服务商和二级商户余额查询接口
f00lish Sep 13, 2020
91d484f
:new: #1759 微信支付增加电商收付通请求分账接口
f00lish Sep 13, 2020
37a009c
:new: #1723 企业微信增加查询应用消息发送统计的接口
binarywang Sep 13, 2020
cc83bcb
:bookmark: 发布 3.9.2.B 测试版本
binarywang Sep 13, 2020
3fbeec4
Merge remote-tracking branch 'wechat/develop' into develop
Sep 14, 2020
7c10cdd
:new: #1764 微信支付电商收付通增加请求分账回退接口
f00lish Sep 14, 2020
e56289f
Merge remote-tracking branch 'wechat/develop' into develop
Sep 15, 2020
b660bfd
:bug: #1766 修复电商收付通请求分账结果类未添加相关注解的问题
f00lish Sep 17, 2020
60c63a5
fix:电商收付通回调通知测试
Sep 17, 2020
5b606fd
Merge remote-tracking branch 'wechat/develop' into develop
Sep 17, 2020
115f910
:new: #1768 微信支付增加电商收付通完结分账和退款接口
f00lish Sep 18, 2020
7261f23
:new: #1767 企业微信外部联系人增加修改客户备注信息的接口
binarywang Sep 19, 2020
e00320d
:art: 优化部分代码
binarywang Sep 19, 2020
cdda57d
:art: #1646 企业微信第三方应用(服务商)模块重构实现,并提供Router、Interceptor、Handler等接口
binarywang Sep 20, 2020
489942a
:art: #1755 完善补充第三方平台小程序相关的部分错误码
binarywang Sep 20, 2020
6713787
:art: 优化企业微信群机器人发送消息的相关接口,提供无需提前设置webhookKey即可使用的重构方法
binarywang Sep 20, 2020
1598c61
:new: #1675 企业微信增加创建日历的接口,以及相关回调事件消息通知的支持
binarywang Sep 20, 2020
020cd0a
:bookmark: 发布 3.9.3.B 测试版本
binarywang Sep 20, 2020
aa2fe98
Merge remote-tracking branch 'wechat/develop' into develop
Sep 20, 2020
9b20c74
new:电商收付通合单支付、普通支付查询
Sep 21, 2020
00bc965
new:电商收付通商户、平台提现
Sep 21, 2020
2037900
fix:命名统一调整
Sep 21, 2020
5f0d1b3
:new: #1772 电商收付通增加支付结果查询和提现的接口
cloudX2019 Sep 22, 2020
3b4bb74
Merge remote-tracking branch 'wechat/develop' into develop
Sep 22, 2020
58ac339
new:分账查询、退款通知
Sep 22, 2020
7df0e75
new:修改结算账户、退款查询
Sep 23, 2020
807ed7d
:new: #1775 微信支付电商收付通增加修改二级商户结算账户和退款查询的接口
cloudX2019 Sep 23, 2020
07edd5b
Merge remote-tracking branch 'wechat/develop' into develop
Sep 23, 2020
e0c995e
:bug: #1777 XML工具类修复无法解析<ExtAttr><Item>这种节点数据的问题
giveme0101 Sep 24, 2020
697a680
:art: WxMpMessageRouter增加构造方法
binarywang Sep 24, 2020
32f7277
:art: 升级依赖jodd-http版本,并修复不兼容代码
binarywang Sep 24, 2020
17583a4
:art: 优化GraalProcessor代码
binarywang Sep 24, 2020
f0f21e1
Merge remote-tracking branch 'wechat/develop' into develop
Sep 25, 2020
f212f02
#1782 微信支付修复分账回退查询接口签名错误的问题
lmhfq Sep 26, 2020
5ecfaf7
:new: #1774 企业微信增加系统审批事件推送的事件常量
binarywang Sep 26, 2020
1d73443
:art: 优化代码
binarywang Sep 26, 2020
a28a17a
Merge remote-tracking branch 'wechat/develop' into develop
Sep 27, 2020
7e3e16d
:art: #1785 公众号 spring boot starter 模块增加接口自定义主机地址和redis sentinel的配置
Dream2Land Sep 27, 2020
b797152
:bookmark: 发布 3.9.4.B 测试版本
binarywang Sep 27, 2020
d248c0e
fix:字段错误
Sep 28, 2020
9603199
Merge remote-tracking branch 'wechat/develop' into develop
Sep 28, 2020
429f170
:new: #1789 微信支付电商收付通增加下载账单的接口
f00lish Sep 29, 2020
cd0c63f
修改退款接口字段错误 (#1788)
binarywang Sep 29, 2020
8428270
:new: #1793 企业微信添加应用管理的设置工作台自定义展示模块
youflint Sep 30, 2020
8929fc4
:art: 优化公众号Spring Boot Starter的redisTemplate注入等代码
Dream2Land Oct 2, 2020
18f3f40
:art: 优化代码,提供toString方法,避免某些情况下出现的问题
binarywang Oct 5, 2020
64402ab
:new: #1675 企业微信增加更新、查询和删除日历的接口
binarywang Oct 5, 2020
6948044
:new: #1686 微信公众号增加对话能力(原导购助手)部分接口,如添加顾问、获取顾问信息等
binarywang Oct 6, 2020
9c91aeb
:new: #1686 微信公众号增加对话能力(原导购助手)部分接口,如修改顾问、删除顾问、获取顾问列表等
binarywang Oct 7, 2020
6cc5ebd
:art: #1797 企业微信配置客户联系「联系我」方式接口返回增加二维码链接字段
Acvrock Oct 12, 2020
c7b1abc
:art: 优化部分代码,重构OAuth2网页授权、网页登录等相关接口,方便接入open模块
binarywang Oct 10, 2020
5599c0d
:bug: 修复字段错误
cloudX2019 Oct 13, 2020
7c9e2e4
:new: #1725 微信支付分增加免确认模式(预授权方式)相关接口支持
spvycf Oct 15, 2020
77e3c8e
:new: #1806 开放平台增加第三方平台代公众号实现复用公众号资料快速创建小程序的接口
binarywang Oct 17, 2020
07bc5a5
:new: 微信开发平台模块增加OAuth2相关接口(网页授权、网页登录等)的实现
binarywang Oct 18, 2020
1510041
:art: 优化部分代码,明确出错信息
binarywang Oct 18, 2020
08bb399
:bookmark: 发布 3.9.5.B 测试版本
binarywang Oct 18, 2020
1849890
:new: #1817 企业微信增加批量获取外部联系人详情的接口,同时修复外部联系人中listGroupChat参数失效问题
Oct 23, 2020
449bda4
:art: 优化代码,实现序列化接口
binarywang Oct 23, 2020
15e02d7
:art: #1820 优化更新getTicket方法,调整锁调用时机避免并发问题
jnLaoA Oct 25, 2020
fc6428c
Merge branch 'master' into develop
binarywang Oct 25, 2020
c9d8509
Update CONTRIBUTING.md
binarywang Oct 25, 2020
3c7d470
:new: #1814 微信支付解析扫码支付回调通知增加签名类型的重载方法
binarywang Oct 25, 2020
4654f42
:bookmark: 发布 3.9.6.B 测试版本
binarywang Oct 25, 2020
8bd95bc
:art: 重构部分包结构
binarywang Oct 25, 2020
7eb11c8
:art: #1827 微信支付分相关接口优化
winter4666 Oct 29, 2020
73f30b1
:art: #1832 微信支付电商收付通增加查询提现状态的接口
f00lish Oct 31, 2020
7fdfe2c
:bug: #1824 微信支付修复分账回退接口结果错误码解析错误的问题
binarywang Oct 31, 2020
c584cd0
:art: #1834 微信会员卡基本信息类增加缺少字段 use_limit
binarywang Oct 31, 2020
aa26d6b
:bug: #1828 修复企业微信第三方应用消息路由相关方法参数错误的问题
binarywang Oct 31, 2020
e6a550d
:new: #1831 生成小程序二维码的相关接口增加指定文件路径参数的重载方法
gentryhuang Nov 1, 2020
7bca440
:bookmark: 发布 3.9.7.B 测试版本
binarywang Nov 1, 2020
f2b423b
:art: #1848 刷卡支付接口响应结果类增加服务商调用时的返回字段
Kidwind Nov 3, 2020
474ce2a
:art: 增加点注释
binarywang Nov 4, 2020
a3250c9
:art: #1849 企业微信外部联系人相关接口重构,优化重复代码,同时获取客户详情接口返回增加标签id字段
binarywang Nov 4, 2020
c235018
:art: Update javadoc for WxMaQrcodeService.java
zacksleo Nov 5, 2020
a2de4ac
:bug: #1852 修复个性化菜单clientPlatformType字段的反序列化问题
wcc1433 Nov 5, 2020
b693c5f
:art: 补充完善单元测试
binarywang Nov 5, 2020
9850151
:bug: #1856 【微信支付】修复电商收付通查询退款状态的接口地址
f00lish Nov 6, 2020
3b43911
:art: #1857 【企业微信】获取获取部门成员详情接口返回值增加第三方应用专有的open_userid字段
binarywang Nov 8, 2020
6037002
:bookmark: 发布 3.9.8.B 测试版本
binarywang Nov 8, 2020
bf4c8c2
:art: 修复out_trade_no 字段命名不规范问题
Pancratius Nov 10, 2020
e912587
:memo: add more cases
binarywang Nov 10, 2020
4af70b2
:bug: #1861【微信支付】支付分后付费项目请求类的amount属性改为Integer,允许为空
winter4666 Nov 10, 2020
f301912
:bug: #1864 【微信支付】WxPayConfig类的hashCode和equals方法移除 verifier 字段
xJoeWoo Nov 11, 2020
edc04cb
:new: #1863 【小程序】增加删除直播间、编辑直播间、获取直播间推流地址、获取直播间分享二维码等接口
lipengjun92 Nov 11, 2020
a2074a4
:art: #1867【企业微信】优化完善第三方应用的接入代码
xworks Nov 12, 2020
c605330
:new: #1869 【小程序】增加管理直播间小助手的相关接口
GaoMinzhu Nov 13, 2020
30aca49
:new: #1868 【微信支付】增加通用上传图片接口,支持传入流和文件名参数
f00lish Nov 13, 2020
6d556f8
:art: 优化代码,部分类增加序列化接口实现
binarywang Nov 14, 2020
5986698
:art: 增加点单元测试示例代码
binarywang Nov 15, 2020
384dd35
:bookmark: 发布 3.9.9.B 测试版本
binarywang Nov 15, 2020
940f69a
:arrow_up: 升级xstream版本
binarywang Nov 16, 2020
64d67bb
:arrow_up: Bump xstream
dependabot[bot] Nov 17, 2020
c80e77c
:new: #1873 【企业微信】第三方应用增加网页授权登陆获取访问用户身份和获取访问用户敏感信息的接口
huangxm129 Nov 17, 2020
b351ef7
:bug: 修复字段错误问题
binarywang Nov 17, 2020
1bac8f9
:bug: #1883【公众号】修复卡券导入code接口错误的返回类型
ly8388 Nov 21, 2020
57ab245
:art: 规范变量名
binarywang Nov 21, 2020
b4da5c9
:new: #1885 【微信支付】电商收付通增加资金账单下载的接口
f00lish Nov 24, 2020
e6a3e6e
:new: #1866 【小程序】 增加提审素材上传接口请求执行器
yangyh22 Nov 24, 2020
ff064c8
:art: 重构规范小程序部分代码包结构
binarywang Nov 24, 2020
c0af379
:art: #1888【企业微信】补充完善OA审批回调事件消息部分字段缺失的问题
Gyv12345 Nov 27, 2020
0e21866
:new: #1746: 【企业微信】第三方应用增加授权配置接口,同时增加向员工付款的接口
LeoInnovateLab Nov 29, 2020
b0440e0
:art: #1886 【小程序】创建直播间接口增加二维码地址字段
binarywang Nov 29, 2020
bf92d03
:bookmark: 发布 4.0.0 正式版本
binarywang Nov 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
🎨 优化代码
  • Loading branch information
binarywang committed Sep 26, 2020
commit 1d7344309aa01fe81e956e23d6aa4eace787aa23
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,20 @@ protected void checkBackgroundProcessStarted() {
if (this.backgroundProcessStarted.getAndSet(true)) {
return;
}
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
while (true) {
Thread.sleep(WxMessageInMemoryDuplicateChecker.this.clearPeriod);
Long now = System.currentTimeMillis();
for (Map.Entry<String, Long> entry :
WxMessageInMemoryDuplicateChecker.this.msgId2Timestamp.entrySet()) {
if (now - entry.getValue() > WxMessageInMemoryDuplicateChecker.this.timeToLive) {
WxMessageInMemoryDuplicateChecker.this.msgId2Timestamp.entrySet().remove(entry);
}
Thread t = new Thread(() -> {
try {
while (true) {
Thread.sleep(WxMessageInMemoryDuplicateChecker.this.clearPeriod);
Long now = System.currentTimeMillis();
for (Map.Entry<String, Long> entry :
WxMessageInMemoryDuplicateChecker.this.msgId2Timestamp.entrySet()) {
if (now - entry.getValue() > WxMessageInMemoryDuplicateChecker.this.timeToLive) {
WxMessageInMemoryDuplicateChecker.this.msgId2Timestamp.entrySet().remove(entry);
}
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
});
t.setDaemon(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
public class WxErrorException extends Exception {
private static final long serialVersionUID = -6357149550353160810L;

private WxError error;
private final WxError error;

public WxErrorException(String message) {
this(WxError.builder().errorCode(-1).errorMsg(message).build());
}

public WxErrorException(WxError error) {
super(error.toString());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package me.chanjar.weixin.common.error;

/**
* WxJava专用的runtime exception.
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
* @date 2020-09-26
*/
public class WxRuntimeException extends RuntimeException {
private static final long serialVersionUID = 4881698471192264412L;

public WxRuntimeException(Throwable e) {
super(e);
}

public WxRuntimeException(String msg) {
super(msg);
}

public WxRuntimeException(String msg, Throwable e) {
super(msg, e);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,18 +183,15 @@ protected InternalSession getNewSession() {
public void add(InternalSession session) {
// 当第一次有session创建的时候,开启session清理线程
if (!this.backgroundProcessStarted.getAndSet(true)) {
Thread t = new Thread(new Runnable() {
@Override
public void run() {
while (true) {
try {
// 每秒清理一次
Thread.sleep(StandardSessionManager.this.backgroundProcessorDelay * 1000L);
backgroundProcess();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
StandardSessionManager.this.log.error("SessionManagerImpl.backgroundProcess error", e);
}
Thread t = new Thread(() -> {
while (true) {
try {
// 每秒清理一次
Thread.sleep(StandardSessionManager.this.backgroundProcessorDelay * 1000L);
backgroundProcess();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
StandardSessionManager.this.log.error("SessionManagerImpl.backgroundProcess error", e);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static void checkRequiredFields(Object bean) throws WxErrorException {
if (!requiredFields.isEmpty()) {
String msg = String.format("必填字段【%s】必须提供值!", requiredFields);
log.debug(msg);
throw new WxErrorException(WxError.builder().errorMsg(msg).build());
throw new WxErrorException(msg);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.error.WxRuntimeException;
import org.dom4j.*;
import org.dom4j.io.SAXReader;
import org.dom4j.tree.DefaultText;
Expand Down Expand Up @@ -40,7 +42,7 @@ public static Map<String, Object> xml2Map(String xmlString) {
map.put(element.getName(), element2MapOrString(element));
}
} catch (DocumentException | SAXException e) {
throw new RuntimeException(e);
throw new WxRuntimeException(e);
}

return map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import com.google.common.base.CharMatcher;
import com.google.common.io.BaseEncoding;
import me.chanjar.weixin.common.error.WxRuntimeException;
import org.apache.commons.codec.binary.Base64;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
Expand Down Expand Up @@ -77,7 +78,7 @@ private static String extractEncryptPart(String xml) {
Element root = document.getDocumentElement();
return root.getElementsByTagName("Encrypt").item(0).getTextContent();
} catch (Exception e) {
throw new RuntimeException(e);
throw new WxRuntimeException(e);
}
}

Expand Down Expand Up @@ -198,7 +199,7 @@ protected String encrypt(String randomStr, String plainText) {
// 使用BASE64对加密后的字符串进行编码
return BASE64.encodeToString(encrypted);
} catch (Exception e) {
throw new RuntimeException(e);
throw new WxRuntimeException(e);
}
}

Expand All @@ -224,7 +225,7 @@ public String decrypt(String msgSignature, String timeStamp, String nonce, Strin
// 验证安全签名
String signature = SHA1.gen(this.token, timeStamp, nonce, cipherText);
if (!signature.equals(msgSignature)) {
throw new RuntimeException("加密消息签名校验失败");
throw new WxRuntimeException("加密消息签名校验失败");
}

// 解密
Expand Down Expand Up @@ -252,7 +253,7 @@ public String decrypt(String cipherText) {
// 解密
original = cipher.doFinal(encrypted);
} catch (Exception e) {
throw new RuntimeException(e);
throw new WxRuntimeException(e);
}

String xmlContent;
Expand All @@ -269,12 +270,12 @@ public String decrypt(String cipherText) {
xmlContent = new String(Arrays.copyOfRange(bytes, 20, 20 + xmlLength), CHARSET);
fromAppid = new String(Arrays.copyOfRange(bytes, 20 + xmlLength, bytes.length), CHARSET);
} catch (Exception e) {
throw new RuntimeException(e);
throw new WxRuntimeException(e);
}

// appid不相同的情况 暂时忽略这段判断
// if (!fromAppid.equals(this.appidOrCorpid)) {
// throw new RuntimeException("AppID不正确,请核实!");
// throw new WxRuntimeException("AppID不正确,请核实!");
// }

return xmlContent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public String getFileName() throws WxErrorException {
private String getFileName(CloseableHttpResponse response) throws WxErrorException {
Header[] contentDispositionHeader = response.getHeaders("Content-disposition");
if (contentDispositionHeader == null || contentDispositionHeader.length == 0) {
throw new WxErrorException(WxError.builder().errorMsg("无法获取到文件名").errorCode(99999).build());
throw new WxErrorException("无法获取到文件名");
}

return this.extractFileNameFromContentString(contentDispositionHeader[0].getValue());
Expand All @@ -76,15 +76,15 @@ private String getFileName(Response response) throws WxErrorException {

private String extractFileNameFromContentString(String content) throws WxErrorException {
if (content == null || content.length() == 0) {
throw new WxErrorException(WxError.builder().errorMsg("无法获取到文件名").errorCode(99999).build());
throw new WxErrorException("无法获取到文件名");
}

Matcher m = PATTERN.matcher(content);
if (m.matches()) {
return m.group(1);
}

throw new WxErrorException(WxError.builder().errorMsg("无法获取到文件名").errorCode(99999).build());
throw new WxErrorException("无法获取到文件名");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static RequestExecutor<String, String> create(RequestHttp requestHttp) {
@NotNull
public String handleResponse(WxType wxType, String responseContent) throws WxErrorException {
if (responseContent.isEmpty()) {
throw new WxErrorException(WxError.builder().errorCode(9999).errorMsg("无响应内容").build());
throw new WxErrorException("无响应内容");
}

if (responseContent.startsWith("<xml>")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import jodd.util.MathUtil;
import me.chanjar.weixin.common.error.WxRuntimeException;

import java.util.List;

Expand Down Expand Up @@ -173,7 +174,7 @@ public static JsonObject buildJsonObject(Object... keyOrValue) {
*/
public static void put(JsonObject jsonObject, Object... keyOrValue) {
if (MathUtil.isOdd(keyOrValue.length)) {
throw new RuntimeException("参数个数必须为偶数");
throw new WxRuntimeException("参数个数必须为偶数");
}

for (int i = 0; i < keyOrValue.length / 2; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.concurrent.locks.Lock;

import com.github.jedis.lock.JedisLock;
import me.chanjar.weixin.common.error.WxRuntimeException;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.util.Pool;

Expand All @@ -26,18 +27,18 @@ public JedisDistributedLock(Pool<Jedis> jedisPool, String key){
public void lock() {
try (Jedis jedis = jedisPool.getResource()) {
if (!lock.acquire(jedis)) {
throw new RuntimeException("acquire timeouted");
throw new WxRuntimeException("acquire timeouted");
}
} catch (InterruptedException e) {
throw new RuntimeException("lock failed", e);
throw new WxRuntimeException("lock failed", e);
}
}

@Override
public void lockInterruptibly() throws InterruptedException {
try (Jedis jedis = jedisPool.getResource()) {
if (!lock.acquire(jedis)) {
throw new RuntimeException("acquire timeouted");
throw new WxRuntimeException("acquire timeouted");
}
}
}
Expand All @@ -47,7 +48,7 @@ public boolean tryLock() {
try (Jedis jedis = jedisPool.getResource()) {
return lock.acquire(jedis);
} catch (InterruptedException e) {
throw new RuntimeException("lock failed", e);
throw new WxRuntimeException("lock failed", e);
}
}

Expand All @@ -67,7 +68,7 @@ public void unlock() {

@Override
public Condition newCondition() {
throw new RuntimeException("unsupported method");
throw new WxRuntimeException("unsupported method");
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package me.chanjar.weixin.common.util.locks;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.testng.annotations.BeforeTest;
Expand All @@ -12,6 +12,7 @@

import static org.testng.Assert.*;

@Slf4j
@Test(enabled = false)
public class RedisTemplateSimpleDistributedLockTest {

Expand Down Expand Up @@ -40,19 +41,19 @@ public void testLockExclusive() throws InterruptedException {
final CountDownLatch endLatch = new CountDownLatch(threadSize);

for (int i = 0; i < threadSize; i++) {
new Thread(new Runnable() {
@SneakyThrows
@Override
public void run() {
new Thread(() -> {
try {
startLatch.await();
} catch (InterruptedException e) {
log.error("unexpected exception", e);
}

redisLock.lock();
assertEquals(lockCurrentExecuteCounter.incrementAndGet(), 1, "临界区同时只能有一个线程执行");
lockCurrentExecuteCounter.decrementAndGet();
redisLock.unlock();
redisLock.lock();
assertEquals(lockCurrentExecuteCounter.incrementAndGet(), 1, "临界区同时只能有一个线程执行");
lockCurrentExecuteCounter.decrementAndGet();
redisLock.unlock();

endLatch.countDown();
}
endLatch.countDown();
}).start();
startLatch.countDown();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.common.session.StandardSessionManager;
import me.chanjar.weixin.common.session.WxSession;
import me.chanjar.weixin.common.session.WxSessionManager;
Expand Down Expand Up @@ -227,7 +228,7 @@ public <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) thro
if (retryTimes + 1 > this.maxRetryTimes) {
log.warn("重试达到最大次数【{}】", this.maxRetryTimes);
//最后一次重试失败后,直接抛出异常,不再等待
throw new RuntimeException("微信服务端异常,超出重试次数");
throw new WxRuntimeException("微信服务端异常,超出重试次数");
}

WxError error = e.getError();
Expand All @@ -249,7 +250,7 @@ public <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) thro
} while (retryTimes++ < this.maxRetryTimes);

log.warn("重试达到最大次数【{}】", this.maxRetryTimes);
throw new RuntimeException("微信服务端异常,超出重试次数");
throw new WxRuntimeException("微信服务端异常,超出重试次数");
}

protected <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException {
Expand Down Expand Up @@ -285,7 +286,7 @@ protected <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E
return null;
} catch (IOException e) {
log.error("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uriWithAccessToken, dataForLog, e.getMessage());
throw new RuntimeException(e);
throw new WxRuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.RequiredArgsConstructor;
import me.chanjar.weixin.common.error.WxCpErrorMsgEnum;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.cp.api.WxCpExternalContactService;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
Expand All @@ -30,7 +31,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
public WxCpContactWayResult addContactWay(@NonNull WxCpContactWayInfo info) throws WxErrorException {

if (info.getContactWay().getUsers() != null && info.getContactWay().getUsers().size() > 100) {
throw new RuntimeException("「联系我」使用人数默认限制不超过100人(包括部门展开后的人数)");
throw new WxRuntimeException("「联系我」使用人数默认限制不超过100人(包括部门展开后的人数)");
}

final String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_CONTACT_WAY);
Expand All @@ -52,10 +53,10 @@ public WxCpContactWayInfo getContactWay(@NonNull String configId) throws WxError
@Override
public WxCpBaseResp updateContactWay(@NonNull WxCpContactWayInfo info) throws WxErrorException {
if (StringUtils.isBlank(info.getContactWay().getConfigId())) {
throw new RuntimeException("更新「联系我」方式需要指定configId");
throw new WxRuntimeException("更新「联系我」方式需要指定configId");
}
if (info.getContactWay().getUsers() != null && info.getContactWay().getUsers().size() > 100) {
throw new RuntimeException("「联系我」使用人数默认限制不超过100人(包括部门展开后的人数)");
throw new WxRuntimeException("「联系我」使用人数默认限制不超过100人(包括部门展开后的人数)");
}

final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_CONTACT_WAY);
Expand Down
Loading