Skip to content

Commit 65d0ae6

Browse files
committed
spring-projectsGH-3379: Spring Boot 4.x compatibility
- Updated Spring Boot dependency to 4.0.0.RC1 - Spring Framework 7 API compatibility (see below) - Migration to Spring Boot 4.x as per https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-4.0-Migration-Guide : * Adopt new modular design of starters * Use new Jackson 3.x API * Support Property Mapper API changes around null handling * Migrated from Spring Retry to Spring Framework Retry functionality - Updated Swagger codegen templates used by huggingface model to align with latest Spring Framework APIs - Update elasticsearch test container to 9.2.0 - Added `FailureDetectingExternalResource` from old versions of `testcontainers` library to support `gemfire-testcontainers` - Other related dependencies updates: * TestContainers to 2.0.1 * GemFire testcontainers to 2.3.3 * opensearch-testcontainers to 4.0.0 * Rest Assured to 5.5.6 * swagger-codegen-maven-plugin to 3.0.75 Fixes spring-projectsGH-3379 (spring-projects#3379) Includes changes by @paulbakker from spring-projects#4681 Built on-top of spring-projects#4771 - Use only Spring Framework APIs available both in 6.x and 7.x branches - Add constructors without logic to `*Api` classes in `models` modules to simplify extensibility; effective final fields are marked as final - Kotlin 2.x support; use kotlin compiler version 2.2.21 - Update MCP SDK to 0.15.0 - Update MCP Annotations to 0.6.0 Future tasks: - [x] Raise issue to migrate from Spring Retry to Spring Framework 7 built-in retry functionality: spring-projects#4681 - [ ] Raise issue with `swagger-codegen-maven-plugin` to support Spring Framework 7 - [x] Raise issue with GemFire to support testcontainers 2.x: gemfire/gemfire-testcontainers#7 Signed-off-by: Dmitry Bedrin <[email protected]>
1 parent a572009 commit 65d0ae6

File tree

276 files changed

+2525
-1056
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

276 files changed

+2525
-1056
lines changed

auto-configurations/common/spring-ai-autoconfigure-retry/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@
6161
<artifactId>spring-boot-starter-test</artifactId>
6262
<scope>test</scope>
6363
</dependency>
64+
<dependency>
65+
<groupId>org.springframework.boot</groupId>
66+
<artifactId>spring-boot-starter-restclient-test</artifactId>
67+
<scope>test</scope>
68+
</dependency>
6469

6570
<dependency>
6671
<groupId>org.mockito</groupId>

auto-configurations/common/spring-ai-autoconfigure-retry/src/main/java/org/springframework/ai/retry/autoconfigure/SpringAiRetryAutoConfiguration.java

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
package org.springframework.ai.retry.autoconfigure;
1818

1919
import java.io.IOException;
20+
import java.net.URI;
2021
import java.nio.charset.StandardCharsets;
22+
import java.util.concurrent.atomic.AtomicInteger;
2123

2224
import org.slf4j.Logger;
2325
import org.slf4j.LoggerFactory;
@@ -30,12 +32,13 @@
3032
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
3133
import org.springframework.boot.context.properties.EnableConfigurationProperties;
3234
import org.springframework.context.annotation.Bean;
35+
import org.springframework.core.retry.RetryListener;
36+
import org.springframework.core.retry.RetryPolicy;
37+
import org.springframework.core.retry.RetryTemplate;
38+
import org.springframework.core.retry.Retryable;
39+
import org.springframework.http.HttpMethod;
3340
import org.springframework.http.client.ClientHttpResponse;
3441
import org.springframework.lang.NonNull;
35-
import org.springframework.retry.RetryCallback;
36-
import org.springframework.retry.RetryContext;
37-
import org.springframework.retry.RetryListener;
38-
import org.springframework.retry.support.RetryTemplate;
3942
import org.springframework.util.CollectionUtils;
4043
import org.springframework.util.StreamUtils;
4144
import org.springframework.web.client.ResponseErrorHandler;
@@ -58,21 +61,25 @@ public class SpringAiRetryAutoConfiguration {
5861
@Bean
5962
@ConditionalOnMissingBean
6063
public RetryTemplate retryTemplate(SpringAiRetryProperties properties) {
61-
return RetryTemplate.builder()
64+
RetryPolicy retryPolicy = RetryPolicy.builder()
6265
.maxAttempts(properties.getMaxAttempts())
63-
.retryOn(TransientAiException.class)
64-
.exponentialBackoff(properties.getBackoff().getInitialInterval(), properties.getBackoff().getMultiplier(),
65-
properties.getBackoff().getMaxInterval())
66-
.withListener(new RetryListener() {
67-
68-
@Override
69-
public <T, E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback,
70-
Throwable throwable) {
71-
logger.warn("Retry error. Retry count: {}, Exception: {}", context.getRetryCount(),
72-
throwable.getMessage(), throwable);
73-
}
74-
})
66+
.includes(TransientAiException.class)
67+
.delay(properties.getBackoff().getInitialInterval())
68+
.multiplier(properties.getBackoff().getMultiplier())
69+
.maxDelay(properties.getBackoff().getMaxInterval())
7570
.build();
71+
72+
RetryTemplate retryTemplate = new RetryTemplate(retryPolicy);
73+
retryTemplate.setRetryListener(new RetryListener() {
74+
private final AtomicInteger retryCount = new AtomicInteger(0);
75+
76+
@Override
77+
public void onRetryFailure(RetryPolicy policy, Retryable<?> retryable, Throwable throwable) {
78+
int currentRetries = this.retryCount.incrementAndGet();
79+
logger.warn("Retry error. Retry count:{}", currentRetries, throwable);
80+
}
81+
});
82+
return retryTemplate;
7683
}
7784

7885
@Bean
@@ -87,6 +94,12 @@ public boolean hasError(@NonNull ClientHttpResponse response) throws IOException
8794
}
8895

8996
@Override
97+
public void handleError(@NonNull URI url, @NonNull HttpMethod method, @NonNull ClientHttpResponse response)
98+
throws IOException {
99+
handleError(response);
100+
}
101+
102+
@SuppressWarnings("removal")
90103
public void handleError(@NonNull ClientHttpResponse response) throws IOException {
91104
if (!response.getStatusCode().isError()) {
92105
return;

auto-configurations/common/spring-ai-autoconfigure-retry/src/test/java/org/springframework/ai/retry/autoconfigure/SpringAiRetryAutoConfigurationIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
import org.junit.jupiter.api.Test;
2020

2121
import org.springframework.boot.autoconfigure.AutoConfigurations;
22-
import org.springframework.boot.autoconfigure.web.client.RestClientAutoConfiguration;
22+
import org.springframework.boot.restclient.autoconfigure.RestClientAutoConfiguration;
2323
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
24-
import org.springframework.retry.support.RetryTemplate;
24+
import org.springframework.core.retry.RetryTemplate;
2525
import org.springframework.web.client.ResponseErrorHandler;
2626

2727
import static org.assertj.core.api.Assertions.assertThat;

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client-httpclient/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282

8383
<dependency>
8484
<groupId>org.testcontainers</groupId>
85-
<artifactId>junit-jupiter</artifactId>
85+
<artifactId>testcontainers-junit-jupiter</artifactId>
8686
<scope>test</scope>
8787
</dependency>
8888
</dependencies>

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client-webflux/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888

8989
<dependency>
9090
<groupId>org.testcontainers</groupId>
91-
<artifactId>junit-jupiter</artifactId>
91+
<artifactId>testcontainers-junit-jupiter</artifactId>
9292
<scope>test</scope>
9393
</dependency>
9494

auto-configurations/mcp/spring-ai-autoconfigure-mcp-server-webflux/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@
9595
<scope>test</scope>
9696
</dependency>
9797

98+
<dependency>
99+
<groupId>org.springframework.boot</groupId>
100+
<artifactId>spring-boot-starter-restclient</artifactId>
101+
<scope>test</scope>
102+
</dependency>
103+
<dependency>
104+
<groupId>org.springframework.boot</groupId>
105+
<artifactId>spring-boot-starter-webclient</artifactId>
106+
<scope>test</scope>
107+
</dependency>
108+
98109
<dependency>
99110
<groupId>org.springframework.ai</groupId>
100111
<artifactId>spring-ai-autoconfigure-model-anthropic</artifactId>

auto-configurations/mcp/spring-ai-autoconfigure-mcp-server-webflux/src/test/java/org/springframework/ai/mcp/server/autoconfigure/McpServerSseWebFluxAutoConfigurationTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616

1717
package org.springframework.ai.mcp.server.autoconfigure;
1818

19-
import com.fasterxml.jackson.databind.ObjectMapper;
2019
import io.modelcontextprotocol.server.transport.WebFluxSseServerTransportProvider;
2120
import org.junit.jupiter.api.Test;
21+
import tools.jackson.databind.DeserializationFeature;
22+
import tools.jackson.databind.ObjectMapper;
2223

2324
import org.springframework.ai.mcp.server.common.autoconfigure.properties.McpServerProperties;
2425
import org.springframework.boot.autoconfigure.AutoConfigurations;
25-
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
2626
import org.springframework.boot.context.properties.EnableConfigurationProperties;
27+
import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration;
2728
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
2829
import org.springframework.context.annotation.Configuration;
2930
import org.springframework.web.reactive.function.server.RouterFunction;
@@ -46,8 +47,7 @@ void shouldConfigureWebFluxTransportWithCustomObjectMapper() {
4647
ObjectMapper objectMapper = context.getBean(ObjectMapper.class);
4748

4849
// Verify that the ObjectMapper is configured to ignore unknown properties
49-
assertThat(objectMapper.getDeserializationConfig()
50-
.isEnabled(com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)).isFalse();
50+
assertThat(objectMapper.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)).isFalse();
5151

5252
// Test with a JSON payload containing unknown fields
5353
// CHECKSTYLE:OFF

auto-configurations/mcp/spring-ai-autoconfigure-mcp-server-webflux/src/test/java/org/springframework/ai/mcp/server/autoconfigure/StreamableMcpAnnotationsWithLLMIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@
6565
import org.springframework.ai.retry.autoconfigure.SpringAiRetryAutoConfiguration;
6666
import org.springframework.ai.tool.ToolCallbackProvider;
6767
import org.springframework.boot.autoconfigure.AutoConfigurations;
68-
import org.springframework.boot.autoconfigure.web.client.RestClientAutoConfiguration;
69-
import org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAutoConfiguration;
68+
import org.springframework.boot.restclient.autoconfigure.RestClientAutoConfiguration;
7069
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
70+
import org.springframework.boot.webclient.autoconfigure.WebClientAutoConfiguration;
7171
import org.springframework.context.ApplicationContext;
7272
import org.springframework.context.annotation.Bean;
7373
import org.springframework.http.server.reactive.HttpHandler;

auto-configurations/models/chat/memory/repository/spring-ai-autoconfigure-model-chat-memory-repository-cassandra/pom.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
4040
<groupId>org.springframework.boot</groupId>
4141
<artifactId>spring-boot-starter</artifactId>
4242
</dependency>
43+
<dependency>
44+
<groupId>org.springframework.boot</groupId>
45+
<artifactId>spring-boot-starter-cassandra</artifactId>
46+
</dependency>
4347

4448
<dependency>
4549
<groupId>org.springframework.boot</groupId>
@@ -83,13 +87,13 @@
8387

8488
<dependency>
8589
<groupId>org.testcontainers</groupId>
86-
<artifactId>junit-jupiter</artifactId>
90+
<artifactId>testcontainers-junit-jupiter</artifactId>
8791
<scope>test</scope>
8892
</dependency>
8993

9094
<dependency>
9195
<groupId>org.testcontainers</groupId>
92-
<artifactId>cassandra</artifactId>
96+
<artifactId>testcontainers-cassandra</artifactId>
9397
<scope>test</scope>
9498
</dependency>
9599

auto-configurations/models/chat/memory/repository/spring-ai-autoconfigure-model-chat-memory-repository-cassandra/src/main/java/org/springframework/ai/model/chat/memory/repository/cassandra/autoconfigure/CassandraChatMemoryRepositoryAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
import org.springframework.ai.chat.memory.repository.cassandra.CassandraChatMemoryRepositoryConfig;
2323
import org.springframework.ai.model.chat.memory.autoconfigure.ChatMemoryAutoConfiguration;
2424
import org.springframework.boot.autoconfigure.AutoConfiguration;
25-
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
2625
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
2726
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
27+
import org.springframework.boot.cassandra.autoconfigure.CassandraAutoConfiguration;
2828
import org.springframework.boot.context.properties.EnableConfigurationProperties;
2929
import org.springframework.context.annotation.Bean;
3030

0 commit comments

Comments
 (0)