[2.0.0] Bump the lib to Spring 3 (#66)

This commit is contained in:
Baikov Dmitrii 2024-07-09 17:41:18 +03:00 committed by GitHub
parent 7f23818021
commit dc7cdd30a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 46 additions and 36 deletions

View File

@ -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

View File

@ -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 }}

28
pom.xml
View File

@ -7,12 +7,12 @@
<parent>
<groupId>dev.vality</groupId>
<artifactId>library-parent-pom</artifactId>
<version>1.0.2</version>
<version>2.0.2</version>
<relativePath/>
</parent>
<artifactId>adapter-common-lib</artifactId>
<version>1.2.13</version>
<version>2.0.0</version>
<packaging>jar</packaging>
<name>adapter-common-lib</name>
@ -44,9 +44,9 @@
<dockerfile.registry>${env.REGISTRY}</dockerfile.registry>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring.version>5.3.20</spring.version>
<spring-boot.version>2.7.0</spring-boot.version>
<jackson.version>2.13.2</jackson.version>
<spring.version>6.1.10</spring.version>
<spring-boot.version>3.3.1</spring-boot.version>
<jackson.version>2.17.1</jackson.version>
<logback.version>1.2.11</logback.version>
</properties>
@ -140,6 +140,16 @@
<version>4.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.3.1</version>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.1.0</version>
</dependency>
<!-- Spring -->
<dependency>
@ -169,7 +179,7 @@
<dependency>
<groupId>org.springframework.vault</groupId>
<artifactId>spring-vault-core</artifactId>
<version>2.3.2</version>
<version>3.1.1</version>
<scope>provided</scope>
</dependency>
@ -209,19 +219,19 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.2</version>
<version>5.10.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.8.2</version>
<version>5.10.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>vault</artifactId>
<version>1.17.5</version>
<version>1.19.8</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@ -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

View File

@ -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 {

View File

@ -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,
public RestTemplate getRestTemplateWithConverters(
ObservationRestTemplateCustomizer observationRestTemplateCustomizer,
List<HttpMessageConverter<?>> messageConverterList,
int networkTimeout) {
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();
}
}