Upgrade to Spring Framework 7.0

* Upgrade to Spring Data `2025.1.0`
* Upgrade to Spring Security `7.0`
* Fix all the compilation errors, including for Kotlin (not clear how they passed before upgrade to SF `7.0`)
This commit is contained in:
Artem Bilan
2025-06-04 16:36:44 -04:00
parent 66de5a2c93
commit 66d76a3aa3
27 changed files with 81 additions and 78 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2022 the original author or authors.
* Copyright 2022-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
package org.springframework.integration.http.aot;
import org.jspecify.annotations.Nullable;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.ReflectionHints;
import org.springframework.aot.hint.RuntimeHints;
@@ -34,7 +36,7 @@ import org.springframework.web.server.WebHandler;
class HttpRuntimeHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
ReflectionHints reflectionHints = hints.reflection();
reflectionHints.registerType(WebHandler.class, MemberCategory.INVOKE_PUBLIC_METHODS);

View File

@@ -1,6 +1,5 @@
/**
* Provides classes to support Spring AOT.
*/
@org.springframework.lang.NonNullApi
@org.springframework.lang.NonNullFields
@org.jspecify.annotations.NullMarked
package org.springframework.integration.http.aot;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2023 the original author or authors.
* Copyright 2016-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,12 +19,13 @@ package org.springframework.integration.http.dsl;
import java.net.URI;
import java.util.function.Function;
import org.jspecify.annotations.Nullable;
import org.springframework.expression.Expression;
import org.springframework.expression.common.LiteralExpression;
import org.springframework.integration.expression.FunctionExpression;
import org.springframework.integration.http.inbound.HttpRequestHandlingController;
import org.springframework.integration.http.inbound.HttpRequestHandlingMessagingGateway;
import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
import org.springframework.util.Assert;
import org.springframework.web.client.RestTemplate;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2024 the original author or authors.
* Copyright 2017-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,8 @@ import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Function;
import org.jspecify.annotations.Nullable;
import org.springframework.core.ResolvableType;
import org.springframework.expression.Expression;
import org.springframework.http.HttpEntity;
@@ -36,7 +38,6 @@ import org.springframework.integration.http.inbound.CrossOrigin;
import org.springframework.integration.http.inbound.RequestMapping;
import org.springframework.integration.http.support.DefaultHttpHeaderMapper;
import org.springframework.integration.mapping.HeaderMapper;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.validation.Validator;
import org.springframework.web.bind.annotation.RequestMethod;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2023 the original author or authors.
* Copyright 2016-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,13 +19,14 @@ package org.springframework.integration.http.dsl;
import java.net.URI;
import java.util.Arrays;
import org.jspecify.annotations.Nullable;
import org.springframework.expression.Expression;
import org.springframework.expression.common.LiteralExpression;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.integration.expression.ValueExpression;
import org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.client.ResponseErrorHandler;
import org.springframework.web.client.RestTemplate;

View File

@@ -1,6 +1,5 @@
/**
* Provides HTTP Components support for Spring Integration Java DSL.
*/
@org.springframework.lang.NonNullApi
@org.springframework.lang.NonNullFields
@org.jspecify.annotations.NullMarked
package org.springframework.integration.http.dsl;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2024 the original author or authors.
* Copyright 2017-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,8 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import org.jspecify.annotations.Nullable;
import org.springframework.core.ResolvableType;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.Expression;
@@ -36,7 +38,6 @@ import org.springframework.integration.gateway.MessagingGatewaySupport;
import org.springframework.integration.http.support.DefaultHttpHeaderMapper;
import org.springframework.integration.http.support.IntegrationWebExchangeBindException;
import org.springframework.integration.mapping.HeaderMapper;
import org.springframework.lang.Nullable;
import org.springframework.messaging.MessageHeaders;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -130,9 +130,9 @@ public class HttpRequestHandlingMessagingGateway extends HttpRequestHandlingEndp
HttpHeaders outputHeaders = response.getHeaders();
HttpHeaders entityHeaders = responseEntity.getHeaders();
entityHeaders.entrySet()
entityHeaders.headerSet()
.stream()
.filter(entry -> !outputHeaders.containsKey(entry.getKey()))
.filter(entry -> !outputHeaders.containsHeader(entry.getKey()))
.forEach(entry -> outputHeaders.put(entry.getKey(), entry.getValue()));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2024 the original author or authors.
* Copyright 2017-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,6 +31,8 @@ import java.util.concurrent.locks.ReentrantLock;
import javax.xml.transform.Source;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.expression.EvaluationContext;
@@ -51,7 +53,6 @@ import org.springframework.integration.http.support.DefaultHttpHeaderMapper;
import org.springframework.integration.mapping.HeaderMapper;
import org.springframework.integration.support.AbstractIntegrationMessageBuilder;
import org.springframework.integration.support.MessageBuilderFactory;
import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,8 @@ import java.net.URI;
import java.util.List;
import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.expression.Expression;
import org.springframework.expression.common.LiteralExpression;
@@ -29,7 +31,6 @@ import org.springframework.http.ResponseEntity;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.integration.expression.ValueExpression;
import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandlingException;
import org.springframework.util.Assert;

View File

@@ -1,6 +1,5 @@
/**
* Provides classes supporting outbound endpoints.
*/
@org.springframework.lang.NonNullApi
@org.springframework.lang.NonNullFields
@org.jspecify.annotations.NullMarked
package org.springframework.integration.http.outbound;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,6 +39,7 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
@@ -51,7 +52,6 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.integration.mapping.HeaderMapper;
import org.springframework.integration.support.utils.IntegrationUtils;
import org.springframework.lang.Nullable;
import org.springframework.messaging.MessageHeaders;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
@@ -773,7 +773,7 @@ public class DefaultHttpHeaderMapper implements HeaderMapper<HttpHeaders>, BeanF
this.logger.debug("inboundHeaderNames=" + Arrays.toString(this.inboundHeaderNames));
}
Map<String, Object> target = new HashMap<>();
Set<String> headerNames = source.keySet();
Set<String> headerNames = source.headerNames();
for (String name : headerNames) {
String lowerName = name.toLowerCase(Locale.ROOT);
if (shouldMapInboundHeader(lowerName)) {
@@ -793,7 +793,7 @@ public class DefaultHttpHeaderMapper implements HeaderMapper<HttpHeaders>, BeanF
String prefixedName = StringUtils.startsWithIgnoreCase(name, this.userDefinedHeaderPrefix)
? name
: this.userDefinedHeaderPrefix + name;
Object value = source.containsKey(prefixedName)
Object value = source.containsHeader(prefixedName)
? getHttpHeader(source, prefixedName)
: getHttpHeader(source, name);
if (value != null) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2022 the original author or authors.
* Copyright 2013-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,7 +44,6 @@ import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.context.request.RequestAttributes;
@@ -129,7 +128,7 @@ public class HttpProxyScenarioTests {
assertThat(httpHeaders.getFirst("If-Unmodified-Since")).isEqualTo(ifUnmodifiedSinceValue);
assertThat(httpHeaders.getFirst("Connection")).isEqualTo("Keep-Alive");
MultiValueMap<String, String> responseHeaders = new LinkedMultiValueMap<>(httpHeaders);
HttpHeaders responseHeaders = HttpHeaders.copyOf(httpHeaders);
responseHeaders.set("Connection", "close");
responseHeaders.set("Content-Disposition", contentDispositionValue);
return new ResponseEntity<>(responseHeaders, HttpStatus.OK);
@@ -190,7 +189,7 @@ public class HttpProxyScenarioTests {
assertThat(((MultiValueMap<String, ?>) entity.getBody()).getFirst("foo"))
.isEqualTo("foo".getBytes());
MultiValueMap<String, String> responseHeaders = new LinkedMultiValueMap<>(httpHeaders);
HttpHeaders responseHeaders = HttpHeaders.copyOf(httpHeaders);
responseHeaders.set("Connection", "close");
responseHeaders.set("Content-Type", "text/plain");
return new ResponseEntity<>(responseHeaders, HttpStatus.OK);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -78,10 +78,10 @@ public class CookieTests {
assertThat(br.readLine()).isNull();
br.close();
assertThat(allHeaders.size()).isEqualTo(3);
assertThat(allHeaders.get(0).containsKey("Cookie")).isFalse();
assertThat(allHeaders.get(1).containsKey("Cookie")).isTrue();
assertThat(allHeaders.get(0).containsHeader("Cookie")).isFalse();
assertThat(allHeaders.get(1).containsHeader("Cookie")).isTrue();
assertThat(allHeaders.get(1).get("Cookie").get(0)).isEqualTo("JSESSIONID=X123");
assertThat(allHeaders.get(2).containsKey("Cookie")).isTrue();
assertThat(allHeaders.get(2).containsHeader("Cookie")).isTrue();
assertThat(allHeaders.get(2).get("Cookie").get(0)).isEqualTo("JSESSIONID=X124");
}
@@ -92,7 +92,7 @@ public class CookieTests {
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) {
return new ClientHttpRequest() {
private HttpHeaders headers = new HttpHeaders();
private final HttpHeaders headers = new HttpHeaders();
public HttpHeaders getHeaders() {
return headers;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,6 @@ import java.io.IOException;
import java.io.Serializable;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
@@ -861,9 +860,9 @@ public class HttpRequestExecutingMessageHandlerTests {
StepVerifier.create(httpHeadersSink.asMono())
.assertNext(headers ->
assertThat(headers)
.containsEntry(HttpHeaders.CONTENT_TYPE,
Arrays.asList(MediaType.APPLICATION_JSON_VALUE)))
assertThat(headers.headerSet())
.contains(Map.entry(HttpHeaders.CONTENT_TYPE,
List.of(MediaType.APPLICATION_JSON_VALUE))))
.verifyComplete();
}

View File

@@ -616,7 +616,7 @@ public class DefaultHttpHeaderMapperFromMessageOutboundTests {
messageHeaders.put("abcdef", "abcdef-value");
HttpHeaders headers = new HttpHeaders();
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
assertThat(headers).hasSize(3);
assertThat(headers.headerSet()).hasSize(3);
assertThat(headers.get("1x")).isNull();
assertThat(headers.get("z1")).isNull();
assertThat(headers.get("abc")).isNull();
@@ -639,7 +639,7 @@ public class DefaultHttpHeaderMapperFromMessageOutboundTests {
messageHeaders.put("Accept", "text/xml");
HttpHeaders headers = new HttpHeaders();
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
assertThat(headers).hasSize(3);
assertThat(headers.headerSet()).hasSize(3);
assertThat(headers.get("foobar")).hasSize(1);
assertThat(headers.getFirst("foobar")).isEqualTo("abc");
assertThat(headers.getContentType().toString()).isEqualTo("text/html");