mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-10-21 02:57:37 +08:00
🎨 优化重构部分代码,抽取公共常量
This commit is contained in:
@@ -146,14 +146,8 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
return getWxOpenService().post(uriWithComponentAccessToken, postData);
|
||||
} catch (WxErrorException e) {
|
||||
WxError error = e.getError();
|
||||
/*
|
||||
* 发生以下情况时尝试刷新access_token
|
||||
* 40001 获取access_token时AppSecret错误,或者access_token无效
|
||||
* 42001 access_token超时
|
||||
* 40014 不合法的access_token,请开发者认真比对access_token的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口
|
||||
*/
|
||||
if (error.getErrorCode() == 42001 || error.getErrorCode() == 40001 || error.getErrorCode() == 40014) {
|
||||
// 强制设置wxMpConfigStorage它的access token过期了,这样在下一次请求里就会刷新access token
|
||||
if (WxConsts.ACCESS_TOKEN_ERROR_CODES.contains(error.getErrorCode())) {
|
||||
// 强制设置access token过期,这样在下一次请求里就会刷新access token
|
||||
Lock lock = this.getWxOpenConfigStorage().getComponentAccessTokenLock();
|
||||
lock.lock();
|
||||
try {
|
||||
@@ -190,13 +184,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
return getWxOpenService().get(uriWithComponentAccessToken, null);
|
||||
} catch (WxErrorException e) {
|
||||
WxError error = e.getError();
|
||||
/*
|
||||
* 发生以下情况时尝试刷新access_token
|
||||
* 40001 获取access_token时AppSecret错误,或者access_token无效
|
||||
* 42001 access_token超时
|
||||
* 40014 不合法的access_token,请开发者认真比对access_token的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口
|
||||
*/
|
||||
if (error.getErrorCode() == 42001 || error.getErrorCode() == 40001 || error.getErrorCode() == 40014) {
|
||||
if (WxConsts.ACCESS_TOKEN_ERROR_CODES.contains(error.getErrorCode())) {
|
||||
// 强制设置wxMpConfigStorage它的access token过期了,这样在下一次请求里就会刷新access token
|
||||
Lock lock = this.getWxOpenConfigStorage().getComponentAccessTokenLock();
|
||||
lock.lock();
|
||||
|
Reference in New Issue
Block a user