Skip to content

Commit

Permalink
🎨 优化部分代码
Browse files Browse the repository at this point in the history
  • Loading branch information
binarywang authored and hywr committed Jun 23, 2021
1 parent d47d687 commit 953b5f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
package me.chanjar.weixin.common.util.http.apache;

import java.io.IOException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHost;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
Expand All @@ -25,10 +20,13 @@
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.protocol.HttpContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.concurrent.NotThreadSafe;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

/**
* httpclient 连接管理器 自带DNS解析.
* <p>大部分代码拷贝自:DefaultApacheHttpClientBuilder</p>
Expand All @@ -50,12 +48,7 @@ public class ApacheHttpDnsClientBuilder implements ApacheHttpClientBuilder {

private DnsResolver dnsResover;

private HttpRequestRetryHandler httpRequestRetryHandler = new HttpRequestRetryHandler() {
@Override
public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
return false;
}
};
private HttpRequestRetryHandler httpRequestRetryHandler = (exception, executionCount, context) -> false;
private SSLConnectionSocketFactory sslConnectionSocketFactory = SSLConnectionSocketFactory.getSocketFactory();
private PlainConnectionSocketFactory plainConnectionSocketFactory = PlainConnectionSocketFactory.getSocketFactory();
private String httpProxyHost;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHost;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
Expand All @@ -26,6 +25,7 @@
import org.apache.http.protocol.HttpContext;
import org.apache.http.ssl.SSLContexts;

import javax.annotation.concurrent.NotThreadSafe;
import javax.net.ssl.SSLContext;
import java.io.IOException;
import java.security.KeyManagementException;
Expand Down

0 comments on commit 953b5f9

Please sign in to comment.