Procházet zdrojové kódy

#324: 修复分布式刷新access_token冲突问题

master
Binary Wang před 7 roky
committed by Binary Wang
rodič
revize
532c1af159
6 změnil soubory, kde provedl 6 přidání a 27 odebrání
  1. +1
    -4
      weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceApacheHttpClientImpl.java
  2. +1
    -4
      weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceJoddHttpImpl.java
  3. +1
    -4
      weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java
  4. +1
    -5
      weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java
  5. +1
    -5
      weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceJoddHttpImpl.java
  6. +1
    -5
      weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java

+ 1
- 4
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceApacheHttpClientImpl.java Zobrazit soubor

@@ -38,10 +38,7 @@ public class WxCpServiceApacheHttpClientImpl extends WxCpServiceAbstractImpl<Clo

@Override
public String getAccessToken(boolean forceRefresh) throws WxErrorException {
if (forceRefresh) {
this.configStorage.expireAccessToken();
}
if (this.configStorage.isAccessTokenExpired()) {
if (this.configStorage.isAccessTokenExpired() || forceRefresh) {
synchronized (this.globalAccessTokenRefreshLock) {
if (this.configStorage.isAccessTokenExpired()) {
String url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?"


+ 1
- 4
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceJoddHttpImpl.java Zobrazit soubor

@@ -29,10 +29,7 @@ public class WxCpServiceJoddHttpImpl extends WxCpServiceAbstractImpl<HttpConnect

@Override
public String getAccessToken(boolean forceRefresh) throws WxErrorException {
if (forceRefresh) {
this.configStorage.expireAccessToken();
}
if (this.configStorage.isAccessTokenExpired()) {
if (this.configStorage.isAccessTokenExpired() || forceRefresh) {
synchronized (this.globalAccessTokenRefreshLock) {
if (this.configStorage.isAccessTokenExpired()) {
String url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?"


+ 1
- 4
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java Zobrazit soubor

@@ -37,10 +37,7 @@ public class WxCpServiceOkHttpImpl extends WxCpServiceAbstractImpl<OkHttpClient,
@Override
public String getAccessToken(boolean forceRefresh) throws WxErrorException {
logger.debug("WxCpServiceOkHttpImpl is running");
if (forceRefresh) {
this.configStorage.expireAccessToken();
}
if (this.configStorage.isAccessTokenExpired()) {
if (this.configStorage.isAccessTokenExpired() || forceRefresh) {
synchronized (this.globalAccessTokenRefreshLock) {
if (this.configStorage.isAccessTokenExpired()) {
String url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?"


+ 1
- 5
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java Zobrazit soubor

@@ -87,11 +87,7 @@ public class WxMaServiceImpl implements WxMaService, RequestHttp<CloseableHttpCl
try {
lock.lock();

if (forceRefresh) {
this.getWxMaConfig().expireAccessToken();
}

if (this.getWxMaConfig().isAccessTokenExpired()) {
if (this.getWxMaConfig().isAccessTokenExpired() || forceRefresh) {
String url = String.format(WxMaService.GET_ACCESS_TOKEN_URL, this.getWxMaConfig().getAppid(),
this.getWxMaConfig().getSecret());
try {


+ 1
- 5
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceJoddHttpImpl.java Zobrazit soubor

@@ -51,11 +51,7 @@ public class WxMpServiceJoddHttpImpl extends WxMpServiceAbstractImpl<HttpConnect
try {
lock.lock();

if (forceRefresh) {
this.getWxMpConfigStorage().expireAccessToken();
}

if (this.getWxMpConfigStorage().isAccessTokenExpired()) {
if (this.getWxMpConfigStorage().isAccessTokenExpired() || forceRefresh) {
String url = String.format(WxMpService.GET_ACCESS_TOKEN_URL,
this.getWxMpConfigStorage().getAppId(), this.getWxMpConfigStorage().getSecret());



+ 1
- 5
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java Zobrazit soubor

@@ -43,11 +43,7 @@ public class WxMpServiceOkHttpImpl extends WxMpServiceAbstractImpl<OkHttpClient,
try {
lock.lock();

if (forceRefresh) {
this.getWxMpConfigStorage().expireAccessToken();
}

if (this.getWxMpConfigStorage().isAccessTokenExpired()) {
if (this.getWxMpConfigStorage().isAccessTokenExpired() || forceRefresh) {
String url = String.format(WxMpService.GET_ACCESS_TOKEN_URL,
this.getWxMpConfigStorage().getAppId(), this.getWxMpConfigStorage().getSecret());



Načítá se…
Zrušit
Uložit