Skip to content

Commit beb0ee9

Browse files
bedrintzolov
authored andcommitted
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 10bc0a7 commit beb0ee9

File tree

276 files changed

+2670
-1041
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

+2670
-1041
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: 31 additions & 33 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,13 +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;
39-
import org.springframework.retry.support.RetryTemplateBuilder;
4042
import org.springframework.util.CollectionUtils;
4143
import org.springframework.util.StreamUtils;
4244
import org.springframework.web.client.ResourceAccessException;
@@ -61,35 +63,25 @@ public class SpringAiRetryAutoConfiguration {
6163
@Bean
6264
@ConditionalOnMissingBean
6365
public RetryTemplate retryTemplate(SpringAiRetryProperties properties) {
64-
RetryTemplateBuilder builder = RetryTemplate.builder()
66+
RetryPolicy retryPolicy = RetryPolicy.builder()
6567
.maxAttempts(properties.getMaxAttempts())
66-
.retryOn(TransientAiException.class)
67-
.retryOn(ResourceAccessException.class)
68-
.exponentialBackoff(properties.getBackoff().getInitialInterval(), properties.getBackoff().getMultiplier(),
69-
properties.getBackoff().getMaxInterval())
70-
.withListener(new RetryListener() {
71-
72-
@Override
73-
public <T, E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback,
74-
Throwable throwable) {
75-
logger.warn("Retry error. Retry count: {}, Exception: {}", context.getRetryCount(),
76-
throwable.getMessage(), throwable);
77-
}
78-
});
79-
80-
// Optionally add WebFlux pre-response network errors if present
81-
try {
82-
Class<?> webClientRequestEx = Class
83-
.forName("org.springframework.web.reactive.function.client.WebClientRequestException");
84-
@SuppressWarnings("unchecked")
85-
Class<? extends Throwable> exClass = (Class<? extends Throwable>) webClientRequestEx;
86-
builder.retryOn(exClass);
87-
}
88-
catch (ClassNotFoundException ignore) {
89-
// WebFlux not on classpath; skip
90-
}
91-
92-
return builder.build();
68+
.includes(TransientAiException.class)
69+
.delay(properties.getBackoff().getInitialInterval())
70+
.multiplier(properties.getBackoff().getMultiplier())
71+
.maxDelay(properties.getBackoff().getMaxInterval())
72+
.build();
73+
74+
RetryTemplate retryTemplate = new RetryTemplate(retryPolicy);
75+
retryTemplate.setRetryListener(new RetryListener() {
76+
private final AtomicInteger retryCount = new AtomicInteger(0);
77+
78+
@Override
79+
public void onRetryFailure(RetryPolicy policy, Retryable<?> retryable, Throwable throwable) {
80+
int currentRetries = this.retryCount.incrementAndGet();
81+
logger.warn("Retry error. Retry count:{}", currentRetries, throwable);
82+
}
83+
});
84+
return retryTemplate;
9385
}
9486

9587
@Bean
@@ -104,6 +96,12 @@ public boolean hasError(@NonNull ClientHttpResponse response) throws IOException
10496
}
10597

10698
@Override
99+
public void handleError(@NonNull URI url, @NonNull HttpMethod method, @NonNull ClientHttpResponse response)
100+
throws IOException {
101+
handleError(response);
102+
}
103+
104+
@SuppressWarnings("removal")
107105
public void handleError(@NonNull ClientHttpResponse response) throws IOException {
108106
if (!response.getStatusCode().isError()) {
109107
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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@
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.McpServerObjectMapperAutoConfiguration;
2425
import org.springframework.ai.mcp.server.common.autoconfigure.properties.McpServerProperties;
2526
import org.springframework.boot.autoconfigure.AutoConfigurations;
2627
import org.springframework.boot.context.properties.EnableConfigurationProperties;
28+
import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration;
2729
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
2830
import org.springframework.context.annotation.Configuration;
2931
import org.springframework.web.reactive.function.server.RouterFunction;
@@ -46,8 +48,7 @@ void shouldConfigureWebFluxTransportWithCustomObjectMapper() {
4648
ObjectMapper objectMapper = context.getBean("mcpServerObjectMapper", ObjectMapper.class);
4749

4850
// 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();
51+
assertThat(objectMapper.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)).isFalse();
5152

5253
// Test with a JSON payload containing unknown fields
5354
// 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
@@ -64,9 +64,9 @@
6464
import org.springframework.ai.retry.autoconfigure.SpringAiRetryAutoConfiguration;
6565
import org.springframework.ai.tool.ToolCallbackProvider;
6666
import org.springframework.boot.autoconfigure.AutoConfigurations;
67-
import org.springframework.boot.autoconfigure.web.client.RestClientAutoConfiguration;
68-
import org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAutoConfiguration;
67+
import org.springframework.boot.restclient.autoconfigure.RestClientAutoConfiguration;
6968
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
69+
import org.springframework.boot.webclient.autoconfigure.WebClientAutoConfiguration;
7070
import org.springframework.context.ApplicationContext;
7171
import org.springframework.context.annotation.Bean;
7272
import org.springframework.context.annotation.ComponentScan;

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)