From 742986451d1d604f2fdcbbcd4f712638499d22d2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 8 Dec 2024 06:12:24 +0000 Subject: [PATCH 1/3] chore(deps): update plugin org.springframework.boot to v3.4.0 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index b3a4da9..c5581e9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ spotless_version=6.25.0 jacoco_min_coverage_required=0.84 -spring_boot_version=3.4.0-M1 +spring_boot_version=3.4.0 spring_dependency_management_version=1.1.6 springdoc_openapi_version=2.6.0 From 5d0f1104cd71b74d373c029dc46581f27ce59bd8 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Sun, 8 Dec 2024 06:25:04 +0000 Subject: [PATCH 2/3] Upgrade to SB --- docker/docker-compose.yml | 2 +- gradle.properties | 2 +- .../config/RestClientConfiguration.java | 14 +++++++++++ .../config/RestTemplateConfiguration.java | 25 ------------------- .../mfscreener/config/WebMvcConfig.java | 4 ++- src/main/resources/application.properties | 5 ++++ .../learning/mfscreener/TestApplication.java | 2 +- .../common/SQLContainersConfig.java | 2 +- 8 files changed, 26 insertions(+), 30 deletions(-) create mode 100644 src/main/java/com/learning/mfscreener/config/RestClientConfiguration.java delete mode 100644 src/main/java/com/learning/mfscreener/config/RestTemplateConfiguration.java diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 6422a3d..732a62f 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,7 +1,7 @@ services: postgresqldb: - image: postgres:16.4-alpine + image: postgres:17.2-alpine hostname: postgresqldb container_name: postgresqldb extra_hosts: [ 'host.docker.internal:host-gateway' ] diff --git a/gradle.properties b/gradle.properties index c5581e9..bf7e7e2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,5 +10,5 @@ jacoco_min_coverage_required=0.84 spring_boot_version=3.4.0 spring_dependency_management_version=1.1.6 -springdoc_openapi_version=2.6.0 +springdoc_openapi_version=2.7.0 diff --git a/src/main/java/com/learning/mfscreener/config/RestClientConfiguration.java b/src/main/java/com/learning/mfscreener/config/RestClientConfiguration.java new file mode 100644 index 0000000..ecba461 --- /dev/null +++ b/src/main/java/com/learning/mfscreener/config/RestClientConfiguration.java @@ -0,0 +1,14 @@ +package com.learning.mfscreener.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestClient; + +@Configuration(proxyBeanMethods = false) +public class RestClientConfiguration { + + @Bean + RestClient restClient(RestClient.Builder restClientBuilder) { + return restClientBuilder.build(); + } +} diff --git a/src/main/java/com/learning/mfscreener/config/RestTemplateConfiguration.java b/src/main/java/com/learning/mfscreener/config/RestTemplateConfiguration.java deleted file mode 100644 index 4a90dc8..0000000 --- a/src/main/java/com/learning/mfscreener/config/RestTemplateConfiguration.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.learning.mfscreener.config; - -import java.time.Duration; -import org.springframework.boot.web.client.RestTemplateBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.client.RestClient; -import org.springframework.web.client.RestTemplate; - -@Configuration(proxyBeanMethods = false) -public class RestTemplateConfiguration { - - @Bean - RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) { - return restTemplateBuilder - .setConnectTimeout(Duration.ofSeconds(30)) - .setReadTimeout(Duration.ofSeconds(60)) - .build(); - } - - @Bean - RestClient restClient(RestTemplate restTemplate) { - return RestClient.create(restTemplate); - } -} diff --git a/src/main/java/com/learning/mfscreener/config/WebMvcConfig.java b/src/main/java/com/learning/mfscreener/config/WebMvcConfig.java index 555ce2e..8cfeafb 100644 --- a/src/main/java/com/learning/mfscreener/config/WebMvcConfig.java +++ b/src/main/java/com/learning/mfscreener/config/WebMvcConfig.java @@ -2,12 +2,14 @@ import org.springframework.cache.annotation.EnableCaching; 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; @Configuration(proxyBeanMethods = false) @EnableCaching public class WebMvcConfig implements WebMvcConfigurer { + private final ApplicationProperties applicationProperties; public WebMvcConfig(ApplicationProperties applicationProperties) { @@ -15,7 +17,7 @@ public WebMvcConfig(ApplicationProperties applicationProperties) { } @Override - public void addCorsMappings(CorsRegistry registry) { + public void addCorsMappings(@NonNull CorsRegistry registry) { ApplicationProperties.Cors propertiesCors = applicationProperties.getCors(); registry.addMapping(propertiesCors.getPathPattern()) .allowedMethods(propertiesCors.getAllowedMethods()) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 956ab09..90bcb2c 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -61,3 +61,8 @@ org.jobrunr.miscellaneous.allow-anonymous-data-usage=false org.jobrunr.jobs.metrics.enabled=true org.jobrunr.database.type=sql org.jobrunr.database.datasource=jobrunrDataSource + +# HttpClient +spring.http.client.factory=jdk +spring.http.client.read-timeout=PT1M +spring.http.client.connect-timeout=PT30S diff --git a/src/test/java/com/learning/mfscreener/TestApplication.java b/src/test/java/com/learning/mfscreener/TestApplication.java index 93d01bb..f96d716 100644 --- a/src/test/java/com/learning/mfscreener/TestApplication.java +++ b/src/test/java/com/learning/mfscreener/TestApplication.java @@ -8,9 +8,9 @@ public class TestApplication { public static void main(String[] args) { - System.setProperty("spring.profiles.active", AppConstants.PROFILE_TEST); SpringApplication.from(Application::main) .with(NonSQLContainersConfig.class, SQLContainersConfig.class) + .withAdditionalProfiles(AppConstants.PROFILE_TEST) .run(args); } } diff --git a/src/test/java/com/learning/mfscreener/common/SQLContainersConfig.java b/src/test/java/com/learning/mfscreener/common/SQLContainersConfig.java index fd25285..5389065 100644 --- a/src/test/java/com/learning/mfscreener/common/SQLContainersConfig.java +++ b/src/test/java/com/learning/mfscreener/common/SQLContainersConfig.java @@ -14,6 +14,6 @@ public class SQLContainersConfig { @ServiceConnection @RestartScope PostgreSQLContainer postgreSQLContainer() { - return new PostgreSQLContainer<>(DockerImageName.parse("postgres").withTag("16.4-alpine")); + return new PostgreSQLContainer<>(DockerImageName.parse("postgres").withTag("17.2-alpine")); } } From dc3c689dee0aaab64e9e67997b8ebc29b6197003 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Sun, 8 Dec 2024 06:48:48 +0000 Subject: [PATCH 3/3] fix : starting problem --- .../learning/mfscreener/config/Initializer.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/learning/mfscreener/config/Initializer.java b/src/main/java/com/learning/mfscreener/config/Initializer.java index 0ab6e34..a091645 100644 --- a/src/main/java/com/learning/mfscreener/config/Initializer.java +++ b/src/main/java/com/learning/mfscreener/config/Initializer.java @@ -10,6 +10,7 @@ import java.io.IOException; import java.io.Reader; import java.io.StringReader; +import java.net.URI; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -21,7 +22,7 @@ import org.springframework.util.StringUtils; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.ResourceAccessException; -import org.springframework.web.client.RestTemplate; +import org.springframework.web.client.RestClient; @Component public class Initializer implements CommandLineRunner { @@ -30,17 +31,17 @@ public class Initializer implements CommandLineRunner { private final SchemeService schemeService; private final MfSchemeDtoToEntityMapper mfSchemeDtoToEntityMapper; - private final RestTemplate restTemplate; + private final RestClient restClient; private final MFSchemeNavService mfSchemeNavService; public Initializer( SchemeService schemeService, MfSchemeDtoToEntityMapper mfSchemeDtoToEntityMapper, - RestTemplate restTemplate, + RestClient restClient, MFSchemeNavService mfSchemeNavService) { this.schemeService = schemeService; this.mfSchemeDtoToEntityMapper = mfSchemeDtoToEntityMapper; - this.restTemplate = restTemplate; + this.restClient = restClient; this.mfSchemeNavService = mfSchemeNavService; } @@ -49,7 +50,11 @@ public void run(String... args) throws IOException { long start = System.currentTimeMillis(); LOGGER.info("Loading All Funds..."); try { - String allNAVs = restTemplate.getForObject(AppConstants.AMFI_WEBSITE_LINK, String.class); + String allNAVs = restClient + .get() + .uri(URI.create(AppConstants.AMFI_WEBSITE_LINK)) + .retrieve() + .body(String.class); Reader inputString = new StringReader(Objects.requireNonNull(allNAVs)); List chopArrayList = new ArrayList<>(); try (BufferedReader br = new BufferedReader(inputString)) {