From 45ad3217b058948e7c71513ecba7d31d07ad5c12 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 20 Dec 2024 13:54:15 +0000 Subject: [PATCH 1/7] feat : upgrade to spring boot 3.4.0 --- httpClients/boot-http-proxy/pom.xml | 6 +- .../proxy/config/RestClientConfiguration.java | 86 +++++++++---------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/httpClients/boot-http-proxy/pom.xml b/httpClients/boot-http-proxy/pom.xml index 6410d63e2..cbfab8ad9 100644 --- a/httpClients/boot-http-proxy/pom.xml +++ b/httpClients/boot-http-proxy/pom.xml @@ -6,7 +6,7 @@ org.springframework.boot spring-boot-starter-parent - 3.3.7 + 3.4.1 com.example.rest.proxy @@ -20,7 +20,7 @@ UTF-8 21 - 2.6.0 + 2.7.0 ${project.build.directory}/test-results 2.43.0 @@ -221,7 +221,7 @@ - 1.25.0 + 1.25.2 diff --git a/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/config/RestClientConfiguration.java b/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/config/RestClientConfiguration.java index 2aa8e9aae..e3c02566f 100644 --- a/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/config/RestClientConfiguration.java +++ b/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/config/RestClientConfiguration.java @@ -2,26 +2,24 @@ import com.example.rest.proxy.client.JsonPlaceholderService; import io.micrometer.observation.ObservationRegistry; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; import java.util.List; -import org.apache.hc.client5.http.config.ConnectionConfig; -import org.apache.hc.client5.http.config.RequestConfig; +import javax.net.ssl.SSLContext; import org.apache.hc.client5.http.impl.DefaultConnectionKeepAliveStrategy; -import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; -import org.apache.hc.client5.http.impl.classic.HttpClients; -import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; -import org.apache.hc.client5.http.socket.ConnectionSocketFactory; -import org.apache.hc.client5.http.socket.PlainConnectionSocketFactory; -import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory; -import org.apache.hc.core5.http.config.Registry; -import org.apache.hc.core5.http.config.RegistryBuilder; -import org.apache.hc.core5.http.io.SocketConfig; +import org.apache.hc.client5.http.ssl.DefaultClientTlsStrategy; +import org.apache.hc.client5.http.ssl.HostnameVerificationPolicy; +import org.apache.hc.client5.http.ssl.NoopHostnameVerifier; +import org.apache.hc.core5.ssl.SSLContextBuilder; import org.apache.hc.core5.util.TimeValue; import org.apache.hc.core5.util.Timeout; +import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder; +import org.springframework.boot.http.client.HttpComponentsClientHttpRequestFactoryBuilder; import org.springframework.boot.web.client.RestClientCustomizer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.MediaType; -import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestClient; import org.springframework.web.client.support.RestClientAdapter; import org.springframework.web.service.invoker.HttpServiceProxyFactory; @@ -37,43 +35,46 @@ class RestClientConfiguration { } @Bean - public CloseableHttpClient httpClient() { - Registry registry = - RegistryBuilder.create() - .register("http", PlainConnectionSocketFactory.getSocketFactory()) - .register("https", SSLConnectionSocketFactory.getSocketFactory()) - .build(); - PoolingHttpClientConnectionManager poolingConnectionManager = - new PoolingHttpClientConnectionManager(registry); + public HttpComponentsClientHttpRequestFactoryBuilder + httpComponentsClientHttpRequestFactoryBuilder() { - poolingConnectionManager.setDefaultSocketConfig( - SocketConfig.custom().setSoTimeout(Timeout.ofSeconds(2)).build()); - poolingConnectionManager.setDefaultConnectionConfig( - ConnectionConfig.custom().setConnectTimeout(Timeout.ofSeconds(2)).build()); + SSLContext sslContext; + try { + // Configure SSLContext with a permissive TrustStrategy + sslContext = + SSLContextBuilder.create() + .loadTrustMaterial((chain, authType) -> true) // Trust all certificates + .build(); + } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) { + throw new RuntimeException("Failed to initialize SSL context", e); + } - // set total amount of connections across all HTTP routes - poolingConnectionManager.setMaxTotal(200); - // set maximum amount of connections for each http route in pool - poolingConnectionManager.setDefaultMaxPerRoute(100); - - RequestConfig requestConfig = - RequestConfig.custom() - .setConnectionKeepAlive(TimeValue.ofSeconds(10)) - .setConnectionRequestTimeout(Timeout.ofSeconds(2)) - .setResponseTimeout(Timeout.ofSeconds(2)) - .build(); - - return HttpClients.custom() - .setDefaultRequestConfig(requestConfig) - .setConnectionManager(poolingConnectionManager) - .setKeepAliveStrategy(new DefaultConnectionKeepAliveStrategy()) - .build(); + return ClientHttpRequestFactoryBuilder.httpComponents() + .withHttpClientCustomizer( + httpClientBuilder -> + httpClientBuilder.setKeepAliveStrategy( + DefaultConnectionKeepAliveStrategy.INSTANCE)) + .withConnectionManagerCustomizer( + poolingHttpClientConnectionManagerBuilder -> { + poolingHttpClientConnectionManagerBuilder.setMaxConnTotal(200); + poolingHttpClientConnectionManagerBuilder.setMaxConnPerRoute(100); + poolingHttpClientConnectionManagerBuilder.setTlsSocketStrategy( + new DefaultClientTlsStrategy( + sslContext, + HostnameVerificationPolicy.CLIENT, + NoopHostnameVerifier.INSTANCE)); + }) + .withDefaultRequestConfigCustomizer( + (builder) -> { + builder.setConnectionKeepAlive(TimeValue.ofSeconds(10)); + builder.setConnectionRequestTimeout(Timeout.ofSeconds(30)); + builder.setResponseTimeout(Timeout.ofSeconds(60)); + }); } @Bean RestClientCustomizer restClientCustomizer( ObservationRegistry observationRegistry, - CloseableHttpClient httpClient, LogbookClientHttpRequestInterceptor interceptor) { return restClientBuilder -> restClientBuilder @@ -83,7 +84,6 @@ RestClientCustomizer restClientCustomizer( httpHeaders.setAccept(List.of(MediaType.APPLICATION_JSON)); }) .baseUrl(applicationProperties.getPostServiceUrl()) - .requestFactory(new HttpComponentsClientHttpRequestFactory(httpClient)) .observationRegistry(observationRegistry) .requestInterceptor(interceptor); } From 9eb14fc46e1fccc5295de20b2185137ab7b61596 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 20 Dec 2024 13:58:30 +0000 Subject: [PATCH 2/7] fix : test failure --- .../main/java/com/example/rest/proxy/services/PostService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/services/PostService.java b/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/services/PostService.java index 28b888423..1e92cbb15 100644 --- a/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/services/PostService.java +++ b/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/services/PostService.java @@ -100,6 +100,8 @@ public List savePostComments(List postCommentDtoLis @Transactional public PostResponse savePost(Post post) { Post fetchedPost = jsonPlaceholderService.createPost(post); + // To fix optimisticLock Exception + fetchedPost.setId(null); Post savedPost = postRepository.save(fetchedPost); return postMapper.mapToPostResponse(savedPost); } From fe78bbcc0997fababa10a2d74394dac2fbdb7649 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 20 Dec 2024 14:50:33 +0000 Subject: [PATCH 3/7] fix issue --- .../rest/proxy/services/PostService.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/services/PostService.java b/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/services/PostService.java index 1e92cbb15..2582ee8e6 100644 --- a/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/services/PostService.java +++ b/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/services/PostService.java @@ -101,18 +101,28 @@ public List savePostComments(List postCommentDtoLis public PostResponse savePost(Post post) { Post fetchedPost = jsonPlaceholderService.createPost(post); // To fix optimisticLock Exception - fetchedPost.setId(null); - Post savedPost = postRepository.save(fetchedPost); + // Create a new local entity from the external post + Post localPost = new Post(); + localPost.setUserId(fetchedPost.getUserId()); + localPost.setTitle(fetchedPost.getTitle()); + localPost.setBody(fetchedPost.getBody()); + Post savedPost = postRepository.save(localPost); return postMapper.mapToPostResponse(savedPost); } @Transactional public Post save(Post postEntity) { - return postRepository.save(postEntity); + // Create a new local entity from the external post + Post localPost = new Post(); + localPost.setUserId(postEntity.getUserId()); + localPost.setTitle(postEntity.getTitle()); + localPost.setBody(postEntity.getBody()); + return postRepository.save(localPost); } + @Transactional public PostResponse saveAndConvertToResponse(Post post) { - Post savedPost = save(post); + Post savedPost = postRepository.save(post); return postMapper.mapToPostResponse(savedPost); } From 8cf8fa162dbab3371b0ca34f0e872c2818e9f59e Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 20 Dec 2024 15:00:46 +0000 Subject: [PATCH 4/7] implement review comments --- .../proxy/config/RestClientConfiguration.java | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/config/RestClientConfiguration.java b/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/config/RestClientConfiguration.java index e3c02566f..964229abf 100644 --- a/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/config/RestClientConfiguration.java +++ b/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/config/RestClientConfiguration.java @@ -14,11 +14,14 @@ import org.apache.hc.core5.ssl.SSLContextBuilder; import org.apache.hc.core5.util.TimeValue; import org.apache.hc.core5.util.Timeout; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder; import org.springframework.boot.http.client.HttpComponentsClientHttpRequestFactoryBuilder; import org.springframework.boot.web.client.RestClientCustomizer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.env.Environment; import org.springframework.http.MediaType; import org.springframework.web.client.RestClient; import org.springframework.web.client.support.RestClientAdapter; @@ -28,10 +31,14 @@ @Configuration(proxyBeanMethods = false) class RestClientConfiguration { + private static final Logger log = LoggerFactory.getLogger(RestClientConfiguration.class); + private final ApplicationProperties applicationProperties; + private final Environment environment; - RestClientConfiguration(ApplicationProperties applicationProperties) { + RestClientConfiguration(ApplicationProperties applicationProperties, Environment environment) { this.applicationProperties = applicationProperties; + this.environment = environment; } @Bean @@ -43,7 +50,17 @@ class RestClientConfiguration { // Configure SSLContext with a permissive TrustStrategy sslContext = SSLContextBuilder.create() - .loadTrustMaterial((chain, authType) -> true) // Trust all certificates + .loadTrustMaterial( + (chain, authType) -> { + // For dev/test environments only + if (!isProdEnvironment()) { + log.warn( + "Using permissive certificate validation - NOT FOR PRODUCTION USE"); + return true; + } + // Use default certificate validation for production + return false; + }) // Trust all certificates .build(); } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) { throw new RuntimeException("Failed to initialize SSL context", e); @@ -66,12 +83,17 @@ class RestClientConfiguration { }) .withDefaultRequestConfigCustomizer( (builder) -> { + builder.setProtocolUpgradeEnabled(false); builder.setConnectionKeepAlive(TimeValue.ofSeconds(10)); builder.setConnectionRequestTimeout(Timeout.ofSeconds(30)); builder.setResponseTimeout(Timeout.ofSeconds(60)); }); } + private boolean isProdEnvironment() { + return List.of(environment.getActiveProfiles()).contains("prod"); + } + @Bean RestClientCustomizer restClientCustomizer( ObservationRegistry observationRegistry, From eee54c40a80a6970182448606d6a0809e18f134c Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 20 Dec 2024 15:08:08 +0000 Subject: [PATCH 5/7] Simplify Code --- .../proxy/config/RestClientConfiguration.java | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/config/RestClientConfiguration.java b/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/config/RestClientConfiguration.java index 964229abf..aedfb0ff8 100644 --- a/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/config/RestClientConfiguration.java +++ b/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/config/RestClientConfiguration.java @@ -48,20 +48,12 @@ class RestClientConfiguration { SSLContext sslContext; try { // Configure SSLContext with a permissive TrustStrategy - sslContext = - SSLContextBuilder.create() - .loadTrustMaterial( - (chain, authType) -> { - // For dev/test environments only - if (!isProdEnvironment()) { - log.warn( - "Using permissive certificate validation - NOT FOR PRODUCTION USE"); - return true; - } - // Use default certificate validation for production - return false; - }) // Trust all certificates - .build(); + SSLContextBuilder sslContextBuilder = SSLContextBuilder.create(); + if (!isProdEnvironment()) { + log.warn("Using permissive certificate validation - NOT FOR PRODUCTION USE"); + sslContextBuilder.loadTrustMaterial((chain, authType) -> true); + } + sslContext = sslContextBuilder.build(); } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) { throw new RuntimeException("Failed to initialize SSL context", e); } @@ -79,7 +71,9 @@ class RestClientConfiguration { new DefaultClientTlsStrategy( sslContext, HostnameVerificationPolicy.CLIENT, - NoopHostnameVerifier.INSTANCE)); + isProdEnvironment() + ? null + : NoopHostnameVerifier.INSTANCE)); }) .withDefaultRequestConfigCustomizer( (builder) -> { From e839b1c9133282f8987e09b75db3507616eb31a2 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 20 Dec 2024 15:17:20 +0000 Subject: [PATCH 6/7] removes unnecessary setting --- .../com/example/rest/proxy/config/RestClientConfiguration.java | 1 - 1 file changed, 1 deletion(-) diff --git a/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/config/RestClientConfiguration.java b/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/config/RestClientConfiguration.java index aedfb0ff8..3dcca2932 100644 --- a/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/config/RestClientConfiguration.java +++ b/httpClients/boot-http-proxy/src/main/java/com/example/rest/proxy/config/RestClientConfiguration.java @@ -77,7 +77,6 @@ class RestClientConfiguration { }) .withDefaultRequestConfigCustomizer( (builder) -> { - builder.setProtocolUpgradeEnabled(false); builder.setConnectionKeepAlive(TimeValue.ofSeconds(10)); builder.setConnectionRequestTimeout(Timeout.ofSeconds(30)); builder.setResponseTimeout(Timeout.ofSeconds(60)); From 612e8ba861cfb26517389e7579a808a259296d2c Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 20 Dec 2024 15:49:10 +0000 Subject: [PATCH 7/7] feat: upgrade to sb 3.4.1 --- httpClients/boot-rest-template/pom.xml | 4 +- .../config/RestTemplateConfiguration.java | 79 +++++++++++++------ .../rest/template/config/WebMvcConfig.java | 3 +- 3 files changed, 58 insertions(+), 28 deletions(-) diff --git a/httpClients/boot-rest-template/pom.xml b/httpClients/boot-rest-template/pom.xml index 7b6fbc9f7..1b6a1e781 100644 --- a/httpClients/boot-rest-template/pom.xml +++ b/httpClients/boot-rest-template/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 3.3.7 + 3.4.1 com.example.rest.template @@ -19,7 +19,7 @@ UTF-8 21 - 2.6.0 + 2.7.0 ${project.build.directory}/test-results 2.43.0 diff --git a/httpClients/boot-rest-template/src/main/java/com/example/rest/template/config/RestTemplateConfiguration.java b/httpClients/boot-rest-template/src/main/java/com/example/rest/template/config/RestTemplateConfiguration.java index 5d44b9a45..ff55cf255 100644 --- a/httpClients/boot-rest-template/src/main/java/com/example/rest/template/config/RestTemplateConfiguration.java +++ b/httpClients/boot-rest-template/src/main/java/com/example/rest/template/config/RestTemplateConfiguration.java @@ -9,8 +9,13 @@ import static com.example.rest.template.utils.AppConstants.REQUEST_TIMEOUT; import static com.example.rest.template.utils.AppConstants.SOCKET_TIMEOUT; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; import java.time.Duration; import java.util.Iterator; +import java.util.List; +import javax.net.ssl.SSLContext; import lombok.extern.slf4j.Slf4j; import org.apache.hc.client5.http.ConnectionKeepAliveStrategy; import org.apache.hc.client5.http.HttpRoute; @@ -19,19 +24,20 @@ import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; import org.apache.hc.client5.http.impl.classic.HttpClients; import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; -import org.apache.hc.client5.http.socket.ConnectionSocketFactory; -import org.apache.hc.client5.http.socket.PlainConnectionSocketFactory; -import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder; +import org.apache.hc.client5.http.ssl.DefaultClientTlsStrategy; +import org.apache.hc.client5.http.ssl.HostnameVerificationPolicy; +import org.apache.hc.client5.http.ssl.NoopHostnameVerifier; import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpHost; -import org.apache.hc.core5.http.config.Registry; -import org.apache.hc.core5.http.config.RegistryBuilder; import org.apache.hc.core5.http.io.SocketConfig; +import org.apache.hc.core5.ssl.SSLContextBuilder; import org.apache.hc.core5.util.TimeValue; import org.apache.hc.core5.util.Timeout; import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.env.Environment; import org.springframework.http.MediaType; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.scheduling.TaskScheduler; @@ -45,27 +51,47 @@ @Slf4j public class RestTemplateConfiguration { + private final Environment environment; + + public RestTemplateConfiguration(Environment environment) { + this.environment = environment; + } + @Bean PoolingHttpClientConnectionManager poolingConnectionManager() { - Registry registry = - RegistryBuilder.create() - .register("http", PlainConnectionSocketFactory.getSocketFactory()) - .register("https", SSLConnectionSocketFactory.getSocketFactory()) - .build(); + SSLContext sslContext; + try { + // Configure SSLContext with a permissive TrustStrategy + SSLContextBuilder sslContextBuilder = SSLContextBuilder.create(); + if (!isProdEnvironment()) { + log.warn("Using permissive certificate validation - NOT FOR PRODUCTION USE"); + sslContextBuilder.loadTrustMaterial((chain, authType) -> true); + } + sslContext = sslContextBuilder.build(); + } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) { + throw new RuntimeException("Failed to initialize SSL context", e); + } PoolingHttpClientConnectionManager poolingConnectionManager = - new PoolingHttpClientConnectionManager(registry); - - poolingConnectionManager.setDefaultSocketConfig( - SocketConfig.custom().setSoTimeout(Timeout.ofSeconds(SOCKET_TIMEOUT)).build()); - poolingConnectionManager.setDefaultConnectionConfig( - ConnectionConfig.custom() - .setConnectTimeout(Timeout.ofSeconds(CONNECTION_TIMEOUT)) - .build()); - - // set a total amount of connections across all HTTP routes - poolingConnectionManager.setMaxTotal(MAX_TOTAL_CONNECTIONS); - // set a maximum amount of connections for each HTTP route in pool - poolingConnectionManager.setDefaultMaxPerRoute(MAX_ROUTE_CONNECTIONS); + PoolingHttpClientConnectionManagerBuilder.create() + .setTlsSocketStrategy( + new DefaultClientTlsStrategy( + sslContext, + HostnameVerificationPolicy.CLIENT, + isProdEnvironment() ? null : NoopHostnameVerifier.INSTANCE)) + .setDefaultSocketConfig( + SocketConfig.custom() + .setSoTimeout(Timeout.ofSeconds(SOCKET_TIMEOUT)) + .build()) + .setDefaultConnectionConfig( + ConnectionConfig.custom() + .setConnectTimeout(Timeout.ofSeconds(CONNECTION_TIMEOUT)) + .build()) + // set a total amount of connections across all HTTP routes + .setMaxConnTotal(MAX_TOTAL_CONNECTIONS) + // set a maximum amount of connections for each HTTP route in pool + .setMaxConnPerRoute(MAX_ROUTE_CONNECTIONS) + .build(); + // increase the amounts of connections if the host is localhost HttpHost localhost = new HttpHost("http://localhost", 8080); poolingConnectionManager.setMaxPerRoute( @@ -73,6 +99,10 @@ PoolingHttpClientConnectionManager poolingConnectionManager() { return poolingConnectionManager; } + private boolean isProdEnvironment() { + return List.of(environment.getActiveProfiles()).contains("prod"); + } + @Bean CloseableHttpClient httpClient( PoolingHttpClientConnectionManager poolingConnectionManager, @@ -114,7 +144,7 @@ RestTemplate restTemplate( RestTemplateBuilder restTemplateBuilder, CloseableHttpClient httpClient) { return restTemplateBuilder - .setConnectTimeout(Duration.ofSeconds(60)) + .connectTimeout(Duration.ofSeconds(60)) .defaultHeader( org.springframework.http.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) @@ -125,7 +155,6 @@ RestTemplate restTemplate( log.info("URI: {}", request.getURI()); log.info("HTTP Method: {}", request.getMethod().name()); log.info("HTTP Headers: {}", request.getHeaders()); - return execution.execute(request, body); })) .build(); diff --git a/httpClients/boot-rest-template/src/main/java/com/example/rest/template/config/WebMvcConfig.java b/httpClients/boot-rest-template/src/main/java/com/example/rest/template/config/WebMvcConfig.java index 36cc54cb8..d655655f1 100644 --- a/httpClients/boot-rest-template/src/main/java/com/example/rest/template/config/WebMvcConfig.java +++ b/httpClients/boot-rest-template/src/main/java/com/example/rest/template/config/WebMvcConfig.java @@ -2,6 +2,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Configuration; +import org.springframework.lang.NonNull; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @@ -11,7 +12,7 @@ public class WebMvcConfig implements WebMvcConfigurer { private final ApplicationProperties properties; @Override - public void addCorsMappings(CorsRegistry registry) { + public void addCorsMappings(@NonNull CorsRegistry registry) { registry.addMapping(properties.getCors().getPathPattern()) .allowedMethods(properties.getCors().getAllowedMethods()) .allowedHeaders(properties.getCors().getAllowedHeaders())