cloud.chain.git.api.http.HttpClient Maven / Gradle / Ivy
The newest version!
package cloud.chain.git.api.http;
import okhttp3.ConnectionPool;
import okhttp3.OkHttpClient;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
/**
* wuXiaoMing
* 2023/2/19 11:33
*/
public class HttpClient {
private static OkHttpClient client;
private HttpClient() {
}
public static OkHttpClient getClient() {
if (Objects.nonNull(client)) {
return client;
}
synchronized (HttpClient.class) {
if (Objects.isNull(client)) {
synchronized (HttpClient.class) {
client = new OkHttpClient.Builder()
.connectTimeout(60, TimeUnit.SECONDS)
.writeTimeout(60, TimeUnit.SECONDS)
.readTimeout(60, TimeUnit.SECONDS)
.connectionPool(new ConnectionPool(200, 60, TimeUnit.SECONDS))
.build();
}
}
}
return client;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy