mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-10-30 18:19:04 +08:00
🎨 规范lock.lock()代码,统一放在try代码块之外
Co-authored-by: 谢炳庭 <xiebingting@xiongmaocar.com>
This commit is contained in:
@ -33,8 +33,8 @@ public class WxMaJsapiServiceImpl implements WxMaJsapiService {
|
|||||||
@Override
|
@Override
|
||||||
public String getCardApiTicket(boolean forceRefresh) throws WxErrorException {
|
public String getCardApiTicket(boolean forceRefresh) throws WxErrorException {
|
||||||
Lock lock = this.wxMaService.getWxMaConfig().getCardApiTicketLock();
|
Lock lock = this.wxMaService.getWxMaConfig().getCardApiTicketLock();
|
||||||
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
lock.lock();
|
|
||||||
if (forceRefresh) {
|
if (forceRefresh) {
|
||||||
this.wxMaService.getWxMaConfig().expireCardApiTicket();
|
this.wxMaService.getWxMaConfig().expireCardApiTicket();
|
||||||
}
|
}
|
||||||
@ -60,8 +60,8 @@ public class WxMaJsapiServiceImpl implements WxMaJsapiService {
|
|||||||
@Override
|
@Override
|
||||||
public String getJsapiTicket(boolean forceRefresh) throws WxErrorException {
|
public String getJsapiTicket(boolean forceRefresh) throws WxErrorException {
|
||||||
Lock lock = this.wxMaService.getWxMaConfig().getJsapiTicketLock();
|
Lock lock = this.wxMaService.getWxMaConfig().getJsapiTicketLock();
|
||||||
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
lock.lock();
|
|
||||||
if (forceRefresh) {
|
if (forceRefresh) {
|
||||||
this.wxMaService.getWxMaConfig().expireJsapiTicket();
|
this.wxMaService.getWxMaConfig().expireJsapiTicket();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -101,8 +101,8 @@ public abstract class BaseWxMpServiceImpl<H, P> implements WxMpService, RequestH
|
|||||||
@Override
|
@Override
|
||||||
public String getTicket(TicketType type, boolean forceRefresh) throws WxErrorException {
|
public String getTicket(TicketType type, boolean forceRefresh) throws WxErrorException {
|
||||||
Lock lock = this.getWxMpConfigStorage().getTicketLock(type);
|
Lock lock = this.getWxMpConfigStorage().getTicketLock(type);
|
||||||
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
lock.lock();
|
|
||||||
if (forceRefresh) {
|
if (forceRefresh) {
|
||||||
this.getWxMpConfigStorage().expireTicket(type);
|
this.getWxMpConfigStorage().expireTicket(type);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,8 +49,8 @@ public class WxMpCardServiceImpl implements WxMpCardService {
|
|||||||
public String getCardApiTicket(boolean forceRefresh) throws WxErrorException {
|
public String getCardApiTicket(boolean forceRefresh) throws WxErrorException {
|
||||||
final TicketType type = TicketType.WX_CARD;
|
final TicketType type = TicketType.WX_CARD;
|
||||||
Lock lock = getWxMpService().getWxMpConfigStorage().getTicketLock(type);
|
Lock lock = getWxMpService().getWxMpConfigStorage().getTicketLock(type);
|
||||||
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
lock.lock();
|
|
||||||
|
|
||||||
if (forceRefresh) {
|
if (forceRefresh) {
|
||||||
this.getWxMpService().getWxMpConfigStorage().expireTicket(type);
|
this.getWxMpService().getWxMpConfigStorage().expireTicket(type);
|
||||||
|
|||||||
Reference in New Issue
Block a user