优化部分代码

This commit is contained in:
Binary Wang
2017-10-20 15:19:19 +08:00
parent afb5e6151f
commit 8d6cfce13c
8 changed files with 29 additions and 39 deletions

View File

@@ -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);
}
}

View File

@@ -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) {