Skip to content

Commit dc08dc6

Browse files
committed
Spring Boot 4 compatibility
Signed-off-by: Paul Bakker <[email protected]>
1 parent 8327c0f commit dc08dc6

File tree

234 files changed

+1497
-866
lines changed

Some content is hidden

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

234 files changed

+1497
-866
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@
6262
<scope>test</scope>
6363
</dependency>
6464

65+
<dependency>
66+
<groupId>org.springframework.boot</groupId>
67+
<artifactId>spring-boot-starter-restclient</artifactId>
68+
<scope>test</scope>
69+
</dependency>
70+
6571
<dependency>
6672
<groupId>org.mockito</groupId>
6773
<artifactId>mockito-core</artifactId>

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

Lines changed: 26 additions & 18 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 = retryCount.incrementAndGet();
79+
logger.warn("Retry error. Retry count:{}", currentRetries, throwable);
80+
}
81+
});
82+
return retryTemplate;
7683
}
7784

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

8996
@Override
90-
public void handleError(@NonNull ClientHttpResponse response) throws IOException {
97+
public void handleError(URI url, HttpMethod method, @NonNull ClientHttpResponse response)
98+
throws IOException {
9199
if (!response.getStatusCode().isError()) {
92100
return;
93101
}

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-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,17 +16,17 @@
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;
2221

2322
import org.springframework.ai.mcp.server.common.autoconfigure.properties.McpServerProperties;
2423
import org.springframework.boot.autoconfigure.AutoConfigurations;
25-
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
24+
import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration;
2625
import org.springframework.boot.context.properties.EnableConfigurationProperties;
2726
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
2827
import org.springframework.context.annotation.Configuration;
2928
import org.springframework.web.reactive.function.server.RouterFunction;
29+
import tools.jackson.databind.ObjectMapper;
3030

3131
import static org.assertj.core.api.Assertions.assertThat;
3232

@@ -46,8 +46,8 @@ void shouldConfigureWebFluxTransportWithCustomObjectMapper() {
4646
ObjectMapper objectMapper = context.getBean(ObjectMapper.class);
4747

4848
// 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();
49+
assertThat(objectMapper.deserializationConfig()
50+
.isEnabled(tools.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)).isFalse();
5151

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

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@
5353
<optional>true</optional>
5454
</dependency>
5555

56+
<dependency>
57+
<groupId>org.springframework.boot</groupId>
58+
<artifactId>spring-boot-cassandra</artifactId>
59+
</dependency>
60+
5661
<!-- Test dependencies -->
5762
<dependency>
5863
<groupId>org.springframework.ai</groupId>

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,7 +22,7 @@
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;
25+
import org.springframework.boot.cassandra.autoconfigure.CassandraAutoConfiguration;
2626
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
2727
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
2828
import org.springframework.boot.context.properties.EnableConfigurationProperties;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import org.springframework.ai.chat.messages.MessageType;
3232
import org.springframework.ai.chat.messages.UserMessage;
3333
import org.springframework.boot.autoconfigure.AutoConfigurations;
34-
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
34+
import org.springframework.boot.cassandra.autoconfigure.CassandraAutoConfiguration;
3535
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
3636

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

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@
8181
<version>${azure-identity.version}</version>
8282
</dependency>
8383

84+
<dependency>
85+
<groupId>org.slf4j</groupId>
86+
<artifactId>jcl-over-slf4j</artifactId>
87+
</dependency>
88+
8489
<!-- Test dependencies -->
8590
<dependency>
8691
<groupId>org.springframework.boot</groupId>

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,24 @@
5353
<optional>true</optional>
5454
</dependency>
5555

56+
<dependency>
57+
<groupId>org.springframework.boot</groupId>
58+
<artifactId>spring-boot-jdbc</artifactId>
59+
</dependency>
60+
5661
<!-- Test dependencies -->
5762
<dependency>
5863
<groupId>org.springframework.boot</groupId>
5964
<artifactId>spring-boot-starter-test</artifactId>
6065
<scope>test</scope>
6166
</dependency>
6267

68+
<dependency>
69+
<groupId>org.springframework.boot</groupId>
70+
<artifactId>spring-boot-starter-jdbc</artifactId>
71+
<scope>test</scope>
72+
</dependency>
73+
6374
<dependency>
6475
<groupId>org.postgresql</groupId>
6576
<artifactId>postgresql</artifactId>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import org.springframework.boot.autoconfigure.AutoConfiguration;
2525
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
2626
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
27-
import org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration;
28-
import org.springframework.boot.autoconfigure.sql.init.OnDatabaseInitializationCondition;
27+
import org.springframework.boot.jdbc.autoconfigure.JdbcTemplateAutoConfiguration;
28+
import org.springframework.boot.sql.autoconfigure.init.OnDatabaseInitializationCondition;
2929
import org.springframework.boot.context.properties.EnableConfigurationProperties;
3030
import org.springframework.context.annotation.Bean;
3131
import org.springframework.context.annotation.Conditional;

0 commit comments

Comments
 (0)