Skip to content

Commit a154e30

Browse files
committed
提出部分代码为方法,清晰化代码结构
1 parent 4bd7e61 commit a154e30

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ public class WxMpServiceImpl implements WxMpService {
6767

6868
private HttpHost httpProxy;
6969

70-
public HttpHost getHttpProxy() {
71-
return this.httpProxy;
72-
}
73-
7470
private int retrySleepMillis = 1000;
7571

7672
private int maxRetryTimes = 5;
@@ -421,6 +417,10 @@ protected synchronized <T, E> T executeInternal(RequestExecutor<T, E> executor,
421417
throw new RuntimeException(e);
422418
}
423419
}
420+
421+
public HttpHost getHttpProxy() {
422+
return this.httpProxy;
423+
}
424424

425425
public CloseableHttpClient getHttpclient() {
426426
return this.httpClient;
@@ -429,19 +429,23 @@ public CloseableHttpClient getHttpclient() {
429429
@Override
430430
public void setWxMpConfigStorage(WxMpConfigStorage wxConfigProvider) {
431431
this.wxMpConfigStorage = wxConfigProvider;
432+
this.initHttpClient();
433+
}
432434

435+
private void initHttpClient() {
433436
ApacheHttpClientBuilder apacheHttpClientBuilder = this.wxMpConfigStorage.getApacheHttpClientBuilder();
434437
if (null == apacheHttpClientBuilder) {
435438
apacheHttpClientBuilder = DefaultApacheHttpHttpClientBuilder.get();
436439
}
437-
apacheHttpClientBuilder.httpProxyHost(this.wxMpConfigStorage.getHttp_proxy_host())
438-
.httpProxyPort(this.wxMpConfigStorage.getHttp_proxy_port())
439-
.httpProxyUsername(this.wxMpConfigStorage.getHttp_proxy_username())
440-
.httpProxyPassword(this.wxMpConfigStorage.getHttp_proxy_password());
440+
441+
apacheHttpClientBuilder.httpProxyHost(this.wxMpConfigStorage.getHttpProxyHost())
442+
.httpProxyPort(this.wxMpConfigStorage.getHttpProxyPort())
443+
.httpProxyUsername(this.wxMpConfigStorage.getHttpProxyUsername())
444+
.httpProxyPassword(this.wxMpConfigStorage.getHttpProxyPassword());
441445

442-
if (wxConfigProvider.getSSLContext() != null){
446+
if (this.wxMpConfigStorage.getSSLContext() != null){
443447
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
444-
wxConfigProvider.getSSLContext(),
448+
this.wxMpConfigStorage.getSSLContext(),
445449
new String[] { "TLSv1" },
446450
null,
447451
SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);

0 commit comments

Comments
 (0)