From dc7cdd30a642526fa8233a066ffa692e8cd7a56b Mon Sep 17 00:00:00 2001
From: Baikov Dmitrii <44803026+D-Baykov@users.noreply.github.com>
Date: Tue, 9 Jul 2024 17:41:18 +0300
Subject: [PATCH] [2.0.0] Bump the lib to Spring 3 (#66)
---
.github/workflows/build.yml | 2 +-
.github/workflows/deploy.yml | 2 +-
pom.xml | 28 +++++++++++------
.../common/component/LoggingInterceptor.java | 9 ++----
.../component/NetworkFilterComponent.java | 10 +++---
.../component/RestTemplateComponent.java | 31 +++++++++++--------
6 files changed, 46 insertions(+), 36 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 8b1d094..92f0c6c 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -7,4 +7,4 @@ on:
jobs:
build:
- uses: valitydev/java-workflow/.github/workflows/maven-library-build.yml@v1
+ uses: valitydev/java-workflow/.github/workflows/maven-library-build.yml@v3
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index 58af93b..3ccda4e 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -8,7 +8,7 @@ on:
jobs:
deploy:
- uses: valitydev/java-workflow/.github/workflows/maven-library-deploy.yml@v1
+ uses: valitydev/java-workflow/.github/workflows/maven-library-deploy.yml@v3
secrets:
server-username: ${{ secrets.OSSRH_USERNAME }}
server-password: ${{ secrets.OSSRH_TOKEN }}
diff --git a/pom.xml b/pom.xml
index 75c75f0..603916c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,12 +7,12 @@
dev.vality
library-parent-pom
- 1.0.2
+ 2.0.2
adapter-common-lib
- 1.2.13
+ 2.0.0
jar
adapter-common-lib
@@ -44,9 +44,9 @@
${env.REGISTRY}
UTF-8
UTF-8
- 5.3.20
- 2.7.0
- 2.13.2
+ 6.1.10
+ 3.3.1
+ 2.17.1
1.2.11
@@ -140,6 +140,16 @@
4.0.0
provided
+
+ org.apache.httpcomponents.client5
+ httpclient5
+ 5.3.1
+
+
+ jakarta.servlet
+ jakarta.servlet-api
+ 6.1.0
+
@@ -169,7 +179,7 @@
org.springframework.vault
spring-vault-core
- 2.3.2
+ 3.1.1
provided
@@ -209,19 +219,19 @@
org.junit.jupiter
junit-jupiter-engine
- 5.8.2
+ 5.10.3
test
org.junit.vintage
junit-vintage-engine
- 5.8.2
+ 5.10.3
test
org.testcontainers
vault
- 1.17.5
+ 1.19.8
test
diff --git a/src/main/java/dev/vality/adapter/common/component/LoggingInterceptor.java b/src/main/java/dev/vality/adapter/common/component/LoggingInterceptor.java
index c3daed6..277dbe5 100644
--- a/src/main/java/dev/vality/adapter/common/component/LoggingInterceptor.java
+++ b/src/main/java/dev/vality/adapter/common/component/LoggingInterceptor.java
@@ -49,7 +49,7 @@ public class LoggingInterceptor implements ClientHttpRequestInterceptor {
private void logResponse(int requestNumber, ClientHttpResponse response) throws IOException {
if (log.isDebugEnabled()) {
String prefix = requestNumber + " < ";
- log.debug("{} Response: {} {} {}", prefix, response.getStatusCode(), response.getStatusCode().name(),
+ log.debug("{} Response: {} {} {}", prefix, response.getStatusCode(), response.getStatusCode().value(),
response.getStatusText());
log.debug("{} Headers: {}", prefix, response.getHeaders());
String body = StreamUtils.copyToString(response.getBody(), StandardCharsets.UTF_8);
@@ -74,12 +74,7 @@ public class LoggingInterceptor implements ClientHttpRequestInterceptor {
@Override
public HttpStatus getStatusCode() throws IOException {
- return response.getStatusCode();
- }
-
- @Override
- public int getRawStatusCode() throws IOException {
- return response.getRawStatusCode();
+ return HttpStatus.resolve(response.getStatusCode().value());
}
@Override
diff --git a/src/main/java/dev/vality/adapter/common/component/NetworkFilterComponent.java b/src/main/java/dev/vality/adapter/common/component/NetworkFilterComponent.java
index 6087293..751b045 100644
--- a/src/main/java/dev/vality/adapter/common/component/NetworkFilterComponent.java
+++ b/src/main/java/dev/vality/adapter/common/component/NetworkFilterComponent.java
@@ -4,11 +4,11 @@ import dev.vality.woody.api.flow.WFlow;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.web.filter.OncePerRequestFilter;
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.Filter;
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
public class NetworkFilterComponent {
diff --git a/src/main/java/dev/vality/adapter/common/component/RestTemplateComponent.java b/src/main/java/dev/vality/adapter/common/component/RestTemplateComponent.java
index a1acaa0..807ba88 100644
--- a/src/main/java/dev/vality/adapter/common/component/RestTemplateComponent.java
+++ b/src/main/java/dev/vality/adapter/common/component/RestTemplateComponent.java
@@ -2,9 +2,9 @@ package dev.vality.adapter.common.component;
import dev.vality.woody.api.trace.ContextUtils;
import dev.vality.woody.api.trace.context.TraceContext;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.springframework.boot.actuate.metrics.web.client.MetricsRestTemplateCustomizer;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.springframework.boot.actuate.metrics.web.client.ObservationRestTemplateCustomizer;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.converter.HttpMessageConverter;
@@ -15,18 +15,22 @@ import java.util.List;
public class RestTemplateComponent {
- public RestTemplate getSimpleRestTemplate(MetricsRestTemplateCustomizer metricsRestTemplateCustomizer,
+ public RestTemplate getSimpleRestTemplate(ObservationRestTemplateCustomizer observationRestTemplateCustomizer,
int networkTimeout) {
HttpComponentsClientHttpRequestFactory requestFactory = getRequestFactory(getSimpleHttpClient());
- RestTemplateBuilder restTemplateBuilder = getRestTemplateBuilder(requestFactory, metricsRestTemplateCustomizer);
+ RestTemplateBuilder restTemplateBuilder =
+ getRestTemplateBuilder(requestFactory, observationRestTemplateCustomizer);
return getRestTemplate(restTemplateBuilder, networkTimeout);
}
- public RestTemplate getRestTemplateWithConverters(MetricsRestTemplateCustomizer metricsRestTemplateCustomizer,
- List> messageConverterList,
- int networkTimeout) {
+ public RestTemplate getRestTemplateWithConverters(
+ ObservationRestTemplateCustomizer observationRestTemplateCustomizer,
+ List> messageConverterList,
+ int networkTimeout
+ ) {
HttpComponentsClientHttpRequestFactory requestFactory = getRequestFactory(getSimpleHttpClient());
- RestTemplateBuilder restTemplateBuilder = getRestTemplateBuilder(requestFactory, metricsRestTemplateCustomizer);
+ RestTemplateBuilder restTemplateBuilder =
+ getRestTemplateBuilder(requestFactory, observationRestTemplateCustomizer);
RestTemplate restTemplate = getRestTemplate(restTemplateBuilder, networkTimeout);
restTemplate.setMessageConverters(messageConverterList);
return restTemplate;
@@ -41,11 +45,13 @@ public class RestTemplateComponent {
.build();
}
- public RestTemplateBuilder getRestTemplateBuilder(HttpComponentsClientHttpRequestFactory requestFactory,
- MetricsRestTemplateCustomizer metricsRestTemplateCustomizer) {
+ public RestTemplateBuilder getRestTemplateBuilder(
+ HttpComponentsClientHttpRequestFactory requestFactory,
+ ObservationRestTemplateCustomizer observationRestTemplateCustomizer
+ ) {
return new RestTemplateBuilder()
.requestFactory(() -> requestFactory)
- .additionalCustomizers(metricsRestTemplateCustomizer);
+ .additionalCustomizers(observationRestTemplateCustomizer);
}
public HttpComponentsClientHttpRequestFactory getRequestFactory(CloseableHttpClient httpClient) {
@@ -59,5 +65,4 @@ public class RestTemplateComponent {
.disableAutomaticRetries()
.build();
}
-
}
\ No newline at end of file