feat: 优化rest client
This commit is contained in:
parent
4dabcf6ed1
commit
8c8be418c9
@ -3,6 +3,7 @@ package group.flyfish.rest.core.client;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import group.flyfish.rest.core.exception.RestClientException;
|
||||
import group.flyfish.rest.core.factory.HttpClientFactoryBean;
|
||||
import group.flyfish.rest.core.factory.HttpClientProvider;
|
||||
import group.flyfish.rest.enums.ResponseType;
|
||||
import group.flyfish.rest.utils.JacksonUtil;
|
||||
@ -67,6 +68,7 @@ final class DefaultRestClient implements RestClient {
|
||||
*/
|
||||
DefaultRestClient(HttpRequestBase request) {
|
||||
this.request = request;
|
||||
this.clientProvider = HttpClientFactoryBean::createSSLClient;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -273,7 +275,6 @@ final class DefaultRestClient implements RestClient {
|
||||
return innerExecute();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 内部执行方法,预处理结果
|
||||
*
|
||||
|
@ -28,7 +28,7 @@ public final class HttpClientFactoryBean implements FactoryBean<CloseableHttpCli
|
||||
// 使用非公平锁
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
// 客户端实例,单例
|
||||
private static volatile CloseableHttpClient client;
|
||||
private volatile CloseableHttpClient client;
|
||||
// 配置,配置没进来就不初始化
|
||||
private final RestClientProperties properties;
|
||||
|
||||
@ -42,11 +42,11 @@ public final class HttpClientFactoryBean implements FactoryBean<CloseableHttpCli
|
||||
}
|
||||
|
||||
/**
|
||||
* 不信任的证书请求客户端
|
||||
* 不信任的证书请求客户端(默认客户端)
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
private static CloseableHttpClient createSSLClient() {
|
||||
public static CloseableHttpClient createSSLClient() {
|
||||
//信任所有
|
||||
try {
|
||||
SSLContext context = SSLContextBuilder.create().loadTrustMaterial(null, (arg0, arg1) -> true).build();
|
||||
|
Loading…
Reference in New Issue
Block a user