Merge branch '3.2.x' into 3.3.x

Closes gh-41613
This commit is contained in:
Andy Wilkinson
2024-07-25 16:15:44 +01:00
69 changed files with 279 additions and 302 deletions

View File

@@ -83,8 +83,6 @@ import org.springframework.util.StringUtils;
*/
public class Log4J2LoggingSystem extends AbstractLoggingSystem {
private static final String FILE_PROTOCOL = "file";
private static final String LOG4J_BRIDGE_HANDLER = "org.apache.logging.log4j.jul.Log4jBridgeHandler";
private static final String LOG4J_LOG_MANAGER = "org.apache.logging.log4j.jul.LogManager";

View File

@@ -51,7 +51,6 @@ import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.client.JdkClientHttpRequestFactory;
import org.springframework.http.client.JettyClientHttpRequestFactory;
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
@@ -90,7 +89,8 @@ public final class ClientHttpRequestFactories {
* <ol>
* <li>{@link HttpComponentsClientHttpRequestFactory}</li>
* <li>{@link JettyClientHttpRequestFactory}</li>
* <li>{@link OkHttp3ClientHttpRequestFactory} (deprecated)</li>
* <li>{@link org.springframework.http.client.OkHttp3ClientHttpRequestFactory
* OkHttp3ClientHttpRequestFactory} (deprecated)</li>
* <li>{@link SimpleClientHttpRequestFactory}</li>
* </ol>
* @param settings the settings to apply
@@ -120,7 +120,8 @@ public final class ClientHttpRequestFactories {
* <li>{@link HttpComponentsClientHttpRequestFactory}</li>
* <li>{@link JdkClientHttpRequestFactory}</li>
* <li>{@link JettyClientHttpRequestFactory}</li>
* <li>{@link OkHttp3ClientHttpRequestFactory} (deprecated)</li>
* <li>{@link org.springframework.http.client.OkHttp3ClientHttpRequestFactory
* OkHttp3ClientHttpRequestFactory} (deprecated)</li>
* <li>{@link SimpleClientHttpRequestFactory}</li>
* </ul>
* A {@code requestFactoryType} of {@link ClientHttpRequestFactory} is equivalent to
@@ -149,7 +150,7 @@ public final class ClientHttpRequestFactories {
if (requestFactoryType == SimpleClientHttpRequestFactory.class) {
return (T) Simple.get(settings);
}
if (requestFactoryType == OkHttp3ClientHttpRequestFactory.class) {
if (requestFactoryType == org.springframework.http.client.OkHttp3ClientHttpRequestFactory.class) {
return (T) OkHttp.get(settings);
}
return get(() -> createRequestFactory(requestFactoryType), settings);
@@ -220,21 +221,25 @@ public final class ClientHttpRequestFactories {
}
/**
* Support for {@link OkHttp3ClientHttpRequestFactory}.
* Support for
* {@link org.springframework.http.client.OkHttp3ClientHttpRequestFactory}.
*/
@Deprecated(since = "3.2.0", forRemoval = true)
@SuppressWarnings("removal")
static class OkHttp {
static OkHttp3ClientHttpRequestFactory get(ClientHttpRequestFactorySettings settings) {
OkHttp3ClientHttpRequestFactory requestFactory = createRequestFactory(settings.sslBundle());
static org.springframework.http.client.OkHttp3ClientHttpRequestFactory get(
ClientHttpRequestFactorySettings settings) {
org.springframework.http.client.OkHttp3ClientHttpRequestFactory requestFactory = createRequestFactory(
settings.sslBundle());
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
map.from(settings::connectTimeout).asInt(Duration::toMillis).to(requestFactory::setConnectTimeout);
map.from(settings::readTimeout).asInt(Duration::toMillis).to(requestFactory::setReadTimeout);
return requestFactory;
}
private static OkHttp3ClientHttpRequestFactory createRequestFactory(SslBundle sslBundle) {
private static org.springframework.http.client.OkHttp3ClientHttpRequestFactory createRequestFactory(
SslBundle sslBundle) {
if (sslBundle != null) {
Assert.state(!sslBundle.getOptions().isSpecified(), "SSL Options cannot be specified with OkHttp");
SSLSocketFactory socketFactory = sslBundle.createSslContext().getSocketFactory();
@@ -244,9 +249,9 @@ public final class ClientHttpRequestFactories {
OkHttpClient client = new OkHttpClient.Builder()
.sslSocketFactory(socketFactory, (X509TrustManager) trustManagers[0])
.build();
return new OkHttp3ClientHttpRequestFactory(client);
return new org.springframework.http.client.OkHttp3ClientHttpRequestFactory(client);
}
return new OkHttp3ClientHttpRequestFactory();
return new org.springframework.http.client.OkHttp3ClientHttpRequestFactory();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@@ -29,7 +29,6 @@ import org.springframework.http.client.AbstractClientHttpRequestFactoryWrapper;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.client.JettyClientHttpRequestFactory;
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
@@ -72,7 +71,7 @@ class ClientHttpRequestFactoriesRuntimeHints implements RuntimeHintsRegistrar {
private void registerOkHttpHints(ReflectionHints hints, ClassLoader classLoader) {
hints.registerTypeIfPresent(classLoader, ClientHttpRequestFactories.OKHTTP_CLIENT_CLASS, (typeHint) -> {
typeHint.onReachableType(TypeReference.of(ClientHttpRequestFactories.OKHTTP_CLIENT_CLASS));
registerReflectionHints(hints, OkHttp3ClientHttpRequestFactory.class);
registerReflectionHints(hints, org.springframework.http.client.OkHttp3ClientHttpRequestFactory.class);
});
}

View File

@@ -284,7 +284,6 @@ class StandardConfigDataLocationResolverTests {
void resolveWhenOptionalAndLoaderIsUnknownAndExtensionIsUnknownShouldNotFail() {
ConfigDataLocation location = ConfigDataLocation
.of("optional:some-unknown-loader:dummy.some-unknown-extension");
List<StandardConfigDataResource> locations = this.resolver.resolve(this.context, location);
assertThatNoException().isThrownBy(() -> this.resolver.resolve(this.context, location));
}

View File

@@ -227,6 +227,7 @@ class ConfigurationPropertiesBeanRegistrationAotProcessorTests {
this.counter = counter;
}
@SuppressWarnings("unused")
private ValueObjectWithSpecificConstructorSampleBean(String name) {
this(name, 42);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@@ -37,7 +37,7 @@ import static org.mockito.Mockito.spy;
* @author Stephane Nicoll
* @author Filip Hrisafov
*/
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
class TaskExecutorBuilderTests {
private final TaskExecutorBuilder builder = new TaskExecutorBuilder();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@@ -35,7 +35,7 @@ import static org.mockito.Mockito.spy;
*
* @author Stephane Nicoll
*/
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
class TaskSchedulerBuilderTests {
private final TaskSchedulerBuilder builder = new TaskSchedulerBuilder();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@@ -27,7 +27,6 @@ import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import org.springframework.http.client.AbstractClientHttpRequestFactoryWrapper;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.client.JettyClientHttpRequestFactory;
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.util.ReflectionUtils;
@@ -69,11 +68,15 @@ class ClientHttpRequestFactoriesRuntimeHintsTests {
RuntimeHints hints = new RuntimeHints();
new ClientHttpRequestFactoriesRuntimeHints().registerHints(hints, getClass().getClassLoader());
ReflectionHintsPredicates reflection = RuntimeHintsPredicates.reflection();
assertThat(reflection.onMethod(method(OkHttp3ClientHttpRequestFactory.class, "setConnectTimeout", int.class)))
assertThat(reflection.onMethod(method(org.springframework.http.client.OkHttp3ClientHttpRequestFactory.class,
"setConnectTimeout", int.class)))
.accepts(hints);
assertThat(reflection.onMethod(method(OkHttp3ClientHttpRequestFactory.class, "setReadTimeout", int.class)))
assertThat(reflection.onMethod(method(org.springframework.http.client.OkHttp3ClientHttpRequestFactory.class,
"setReadTimeout", int.class)))
.accepts(hints);
assertThat(hints.reflection().getTypeHint(OkHttp3ClientHttpRequestFactory.class).methods()).hasSize(2);
assertThat(hints.reflection()
.getTypeHint(org.springframework.http.client.OkHttp3ClientHttpRequestFactory.class)
.methods()).hasSize(2);
}
@Test

View File

@@ -27,7 +27,6 @@ import org.springframework.http.client.ClientHttpRequest;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.client.JdkClientHttpRequestFactory;
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import static org.assertj.core.api.Assertions.assertThat;
@@ -72,9 +71,10 @@ class ClientHttpRequestFactoriesTests {
@Deprecated(since = "3.2.0")
@SuppressWarnings("removal")
void getOfOkHttpFactoryReturnsOkHttpFactory() {
ClientHttpRequestFactory requestFactory = ClientHttpRequestFactories.get(OkHttp3ClientHttpRequestFactory.class,
ClientHttpRequestFactory requestFactory = ClientHttpRequestFactories.get(
org.springframework.http.client.OkHttp3ClientHttpRequestFactory.class,
ClientHttpRequestFactorySettings.DEFAULTS);
assertThat(requestFactory).isInstanceOf(OkHttp3ClientHttpRequestFactory.class);
assertThat(requestFactory).isInstanceOf(org.springframework.http.client.OkHttp3ClientHttpRequestFactory.class);
}
@Test