Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update plugin org.springframework.boot to v3.4.0 #400

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:

postgresqldb:
image: postgres:16.6-alpine
image: postgres:17.2-alpine
hostname: postgresqldb
container_name: postgresqldb
extra_hosts: [ 'host.docker.internal:host-gateway' ]
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
springdoc_openapi_version=2.7.0

15 changes: 10 additions & 5 deletions src/main/java/com/learning/mfscreener/config/Initializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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;
}

Expand All @@ -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<MFSchemeDTO> chopArrayList = new ArrayList<>();
try (BufferedReader br = new BufferedReader(inputString)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
Comment on lines +10 to +13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider adding essential RestClient customizations

While the basic configuration is good, consider adding these essential customizations for production readiness:

  • Connection timeout
  • Read timeout
  • Error handling
  • Logging interceptor
 @Bean
 RestClient restClient(RestClient.Builder restClientBuilder) {
-    return restClientBuilder.build();
+    return restClientBuilder
+        .requestInterceptor(new LoggingInterceptor())
+        .defaultHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
+        .defaultStatusHandler(HttpStatusCode::isError,
+            (request, response) -> throw new CustomHttpException(response))
+        .build();
 }

Committable suggestion skipped: line range outside the PR's diff.

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@

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) {
this.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())
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/test/java/com/learning/mfscreener/TestApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
}
Loading