mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-10-14 10:15:08 +08:00
优化部分代码
This commit is contained in:
@@ -37,8 +37,7 @@ public class WxMpMaterialServiceImpl implements WxMpMaterialService {
|
||||
try {
|
||||
return this.mediaUpload(mediaType, FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new WxErrorException(WxError.newBuilder().setErrorMsg(e.getMessage()).build());
|
||||
throw new WxErrorException(WxError.newBuilder().setErrorMsg(e.getMessage()).build(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -8,16 +8,11 @@ import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
|
||||
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import okhttp3.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
public class WxMpServiceOkHttpImpl extends WxMpServiceAbstractImpl<OkHttpClient, OkHttpProxyInfo> {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private OkHttpClient httpClient;
|
||||
private OkHttpProxyInfo httpProxy;
|
||||
|
||||
@@ -38,7 +33,7 @@ public class WxMpServiceOkHttpImpl extends WxMpServiceAbstractImpl<OkHttpClient,
|
||||
|
||||
@Override
|
||||
public String getAccessToken(boolean forceRefresh) throws WxErrorException {
|
||||
logger.debug("WxMpServiceOkHttpImpl is running");
|
||||
this.log.debug("WxMpServiceOkHttpImpl is running");
|
||||
Lock lock = this.getWxMpConfigStorage().getAccessTokenLock();
|
||||
try {
|
||||
lock.lock();
|
||||
@@ -59,7 +54,7 @@ public class WxMpServiceOkHttpImpl extends WxMpServiceAbstractImpl<OkHttpClient,
|
||||
accessToken.getExpiresIn());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
this.log.error(e.getMessage(), e);
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
@@ -68,7 +63,7 @@ public class WxMpServiceOkHttpImpl extends WxMpServiceAbstractImpl<OkHttpClient,
|
||||
|
||||
@Override
|
||||
public void initHttp() {
|
||||
logger.debug("WxMpServiceOkHttpImpl initHttp");
|
||||
this.log.debug("WxMpServiceOkHttpImpl initHttp");
|
||||
WxMpConfigStorage configStorage = this.getWxMpConfigStorage();
|
||||
|
||||
if (configStorage.getHttpProxyHost() != null && configStorage.getHttpProxyPort() > 0) {
|
||||
|
Reference in New Issue
Block a user