Skip to content

Commit

Permalink
Merge pull request #48 from kintone/chore-update-dependencies
Browse files Browse the repository at this point in the history
chore: update dependencies
  • Loading branch information
0gr authored Mar 4, 2024
2 parents df13eb2 + 68c8521 commit 1ff4ac3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
22 changes: 11 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'java'
id 'signing'
id 'maven-publish'
id 'com.diffplug.spotless' version '6.11.0'
id 'com.diffplug.spotless' version '6.13.0'
id 'com.github.hierynomus.license' version '0.16.1'
}

Expand All @@ -24,19 +24,19 @@ artifacts {
}

dependencies {
implementation 'org.apache.httpcomponents.client5:httpclient5:5.1.3'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.4.2'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.4'
implementation 'org.apache.httpcomponents.client5:httpclient5:5.3.1'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.16.1'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.16.1'

compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24'
compileOnly 'org.projectlombok:lombok:1.18.30'
annotationProcessor 'org.projectlombok:lombok:1.18.30'

testImplementation 'com.google.guava:guava:31.1-jre'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.1'
testImplementation 'org.assertj:assertj-core:3.23.1'
testImplementation 'org.mock-server:mockserver-netty:5.14.0'
testImplementation 'com.google.guava:guava:33.0.0-jre'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
testImplementation 'org.assertj:assertj-core:3.25.3'
testImplementation 'org.mock-server:mockserver-netty:5.15.0'

testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2'
}

downloadLicenses {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/kintone/client/HttpResponseImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import java.io.InputStream;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.apache.hc.core5.http.ClassicHttpResponse;

@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class HttpResponseImpl implements HttpResponse {
private final CloseableHttpResponse response;
private final ClassicHttpResponse response;

@Override
public Long getContentLength() {
Expand Down
20 changes: 12 additions & 8 deletions src/main/java/com/kintone/client/InternalClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,20 @@
import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
import org.apache.hc.client5.http.classic.methods.HttpUriRequest;
import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
import org.apache.hc.client5.http.config.ConnectionConfig;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.entity.mime.HttpMultipartMode;
import org.apache.hc.client5.http.entity.mime.InputStreamBody;
import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
import org.apache.hc.client5.http.impl.auth.BasicScheme;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder;
import org.apache.hc.core5.http.*;
import org.apache.hc.core5.http.io.SocketConfig;
import org.apache.hc.core5.http.io.entity.ByteArrayEntity;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.protocol.HttpContext;
Expand Down Expand Up @@ -93,12 +92,15 @@ private static CloseableHttpClient createHttpClient(
int connTimeout,
int socketTimeout,
int connRequestTimeout) {
ConnectionConfig connectionConfig =
ConnectionConfig.custom()
.setConnectTimeout(connTimeout, TimeUnit.MILLISECONDS)
.setSocketTimeout(socketTimeout, TimeUnit.MILLISECONDS)
.build();

RequestConfig.Builder configBuilder = RequestConfig.custom();
configBuilder.setConnectTimeout(connTimeout, TimeUnit.MILLISECONDS);
configBuilder.setConnectionRequestTimeout(connRequestTimeout, TimeUnit.MILLISECONDS);

if (proxyHost != null) {
configBuilder.setProxy(proxyHost);
configBuilder.setProxyPreferredAuthSchemes(Collections.singleton("basic"));
}

Expand All @@ -109,13 +111,15 @@ private static CloseableHttpClient createHttpClient(
.setSslContext(sslContext)
.setTlsVersions(TLS.V_1_3, TLS.V_1_2)
.build())
.setDefaultSocketConfig(
SocketConfig.custom().setSoTimeout(socketTimeout, TimeUnit.MILLISECONDS).build())
.setDefaultConnectionConfig(connectionConfig)
.setPoolConcurrencyPolicy(PoolConcurrencyPolicy.STRICT)
.setConnPoolPolicy(PoolReusePolicy.LIFO)
.build();

HttpClientBuilder clientBuilder = HttpClients.custom();
if (proxyHost != null) {
clientBuilder.setProxy(proxyHost);
}
clientBuilder.setDefaultRequestConfig(configBuilder.build());
clientBuilder.setConnectionManager(connectionManager);
clientBuilder.disableRedirectHandling();
Expand Down Expand Up @@ -248,7 +252,7 @@ DownloadFileResponseBody download(DownloadFileRequest request, List<ResponseHand
HttpUriRequest req = createJsonRequest(KintoneApi.DOWNLOAD_FILE.getMethod(), path, request);
KintoneResponse<DownloadFileResponseBody> r;
try {
CloseableHttpResponse response = httpClient.execute(req, createHttpContext());
ClassicHttpResponse response = httpClient.executeOpen(null, req, createHttpContext());
com.kintone.client.model.HttpResponse resp = new HttpResponseImpl(response);
r = parseResponse(response, stream -> new DownloadFileResponseBody(resp));
} catch (IOException e) {
Expand Down

0 comments on commit 1ff4ac3

Please sign in to comment.