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

@@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.pulsar;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.apache.pulsar.client.api.PulsarClientException;
import org.junit.jupiter.api.Test;
import org.testcontainers.containers.PulsarContainer;
import org.testcontainers.junit.jupiter.Container;
@@ -106,7 +105,7 @@ class PulsarAutoConfigurationIntegrationTests {
}
@GetMapping("/hello")
String sayHello() throws PulsarClientException {
String sayHello() {
return "Hello World -> " + this.pulsarTemplate.send(TOPIC, "hello");
}

View File

@@ -43,7 +43,6 @@ import org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfigurati
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.boot.context.properties.source.MutuallyExclusiveConfigurationPropertiesException;
import org.springframework.boot.task.TaskSchedulerBuilder;
import org.springframework.boot.task.ThreadPoolTaskSchedulerBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
@@ -171,13 +170,14 @@ public class IntegrationAutoConfiguration {
* scheduling explicitly.
*/
@Configuration(proxyBeanMethods = false)
@ConditionalOnBean(TaskSchedulerBuilder.class)
@ConditionalOnBean(org.springframework.boot.task.TaskSchedulerBuilder.class)
@ConditionalOnMissingBean(name = IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME)
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
protected static class IntegrationTaskSchedulerConfiguration {
@Bean(name = IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME)
public ThreadPoolTaskScheduler taskScheduler(TaskSchedulerBuilder taskSchedulerBuilder,
public ThreadPoolTaskScheduler taskScheduler(
org.springframework.boot.task.TaskSchedulerBuilder taskSchedulerBuilder,
ObjectProvider<ThreadPoolTaskSchedulerBuilder> threadPoolTaskSchedulerBuilderProvider) {
ThreadPoolTaskSchedulerBuilder threadPoolTaskSchedulerBuilder = threadPoolTaskSchedulerBuilderProvider
.getIfUnique();

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.
@@ -22,7 +22,6 @@ import java.util.List;
import org.apache.pulsar.client.admin.PulsarAdminBuilder;
import org.apache.pulsar.client.api.ClientBuilder;
import org.apache.pulsar.client.api.PulsarClient;
import org.apache.pulsar.client.api.PulsarClientException;
import org.apache.pulsar.client.api.Schema;
import org.apache.pulsar.common.schema.SchemaType;
@@ -96,7 +95,7 @@ class PulsarConfiguration {
@Bean
@ConditionalOnMissingBean
PulsarClient pulsarClient(PulsarClientFactory clientFactory) throws PulsarClientException {
PulsarClient pulsarClient(PulsarClientFactory clientFactory) {
return clientFactory.createClient();
}

View File

@@ -24,8 +24,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnThreading;
import org.springframework.boot.autoconfigure.thread.Threading;
import org.springframework.boot.task.SimpleAsyncTaskExecutorBuilder;
import org.springframework.boot.task.SimpleAsyncTaskExecutorCustomizer;
import org.springframework.boot.task.TaskExecutorBuilder;
import org.springframework.boot.task.TaskExecutorCustomizer;
import org.springframework.boot.task.ThreadPoolTaskExecutorBuilder;
import org.springframework.boot.task.ThreadPoolTaskExecutorCustomizer;
import org.springframework.context.annotation.Bean;
@@ -49,7 +47,6 @@ class TaskExecutorConfigurations {
@Configuration(proxyBeanMethods = false)
@ConditionalOnMissingBean(Executor.class)
@SuppressWarnings("removal")
static class TaskExecutorConfiguration {
@Bean(name = { TaskExecutionAutoConfiguration.APPLICATION_TASK_EXECUTOR_BEAN_NAME,
@@ -63,7 +60,9 @@ class TaskExecutorConfigurations {
@Bean(name = { TaskExecutionAutoConfiguration.APPLICATION_TASK_EXECUTOR_BEAN_NAME,
AsyncAnnotationBeanPostProcessor.DEFAULT_TASK_EXECUTOR_BEAN_NAME })
@ConditionalOnThreading(Threading.PLATFORM)
ThreadPoolTaskExecutor applicationTaskExecutor(TaskExecutorBuilder taskExecutorBuilder,
@SuppressWarnings({ "deprecation", "removal" })
ThreadPoolTaskExecutor applicationTaskExecutor(
org.springframework.boot.task.TaskExecutorBuilder taskExecutorBuilder,
ObjectProvider<ThreadPoolTaskExecutorBuilder> threadPoolTaskExecutorBuilderProvider) {
ThreadPoolTaskExecutorBuilder threadPoolTaskExecutorBuilder = threadPoolTaskExecutorBuilderProvider
.getIfUnique();
@@ -82,11 +81,11 @@ class TaskExecutorConfigurations {
@Bean
@ConditionalOnMissingBean
@Deprecated(since = "3.2.0", forRemoval = true)
TaskExecutorBuilder taskExecutorBuilder(TaskExecutionProperties properties,
ObjectProvider<TaskExecutorCustomizer> taskExecutorCustomizers,
org.springframework.boot.task.TaskExecutorBuilder taskExecutorBuilder(TaskExecutionProperties properties,
ObjectProvider<org.springframework.boot.task.TaskExecutorCustomizer> taskExecutorCustomizers,
ObjectProvider<TaskDecorator> taskDecorator) {
TaskExecutionProperties.Pool pool = properties.getPool();
TaskExecutorBuilder builder = new TaskExecutorBuilder();
org.springframework.boot.task.TaskExecutorBuilder builder = new org.springframework.boot.task.TaskExecutorBuilder();
builder = builder.queueCapacity(pool.getQueueCapacity());
builder = builder.corePoolSize(pool.getCoreSize());
builder = builder.maxPoolSize(pool.getMaxSize());
@@ -104,14 +103,15 @@ class TaskExecutorConfigurations {
}
@Configuration(proxyBeanMethods = false)
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
static class ThreadPoolTaskExecutorBuilderConfiguration {
@Bean
@ConditionalOnMissingBean({ TaskExecutorBuilder.class, ThreadPoolTaskExecutorBuilder.class })
@ConditionalOnMissingBean({ org.springframework.boot.task.TaskExecutorBuilder.class,
ThreadPoolTaskExecutorBuilder.class })
ThreadPoolTaskExecutorBuilder threadPoolTaskExecutorBuilder(TaskExecutionProperties properties,
ObjectProvider<ThreadPoolTaskExecutorCustomizer> threadPoolTaskExecutorCustomizers,
ObjectProvider<TaskExecutorCustomizer> taskExecutorCustomizers,
ObjectProvider<org.springframework.boot.task.TaskExecutorCustomizer> taskExecutorCustomizers,
ObjectProvider<TaskDecorator> taskDecorator) {
TaskExecutionProperties.Pool pool = properties.getPool();
ThreadPoolTaskExecutorBuilder builder = new ThreadPoolTaskExecutorBuilder();
@@ -132,7 +132,8 @@ class TaskExecutorConfigurations {
return builder;
}
private ThreadPoolTaskExecutorCustomizer adapt(TaskExecutorCustomizer customizer) {
private ThreadPoolTaskExecutorCustomizer adapt(
org.springframework.boot.task.TaskExecutorCustomizer customizer) {
return customizer::customize;
}

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.
@@ -25,8 +25,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnThreading;
import org.springframework.boot.autoconfigure.thread.Threading;
import org.springframework.boot.task.SimpleAsyncTaskSchedulerBuilder;
import org.springframework.boot.task.SimpleAsyncTaskSchedulerCustomizer;
import org.springframework.boot.task.TaskSchedulerBuilder;
import org.springframework.boot.task.TaskSchedulerCustomizer;
import org.springframework.boot.task.ThreadPoolTaskSchedulerBuilder;
import org.springframework.boot.task.ThreadPoolTaskSchedulerCustomizer;
import org.springframework.context.annotation.Bean;
@@ -47,7 +45,6 @@ class TaskSchedulingConfigurations {
@Configuration(proxyBeanMethods = false)
@ConditionalOnBean(name = TaskManagementConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME)
@ConditionalOnMissingBean({ TaskScheduler.class, ScheduledExecutorService.class })
@SuppressWarnings("removal")
static class TaskSchedulerConfiguration {
@Bean(name = "taskScheduler")
@@ -57,8 +54,9 @@ class TaskSchedulingConfigurations {
}
@Bean
@SuppressWarnings({ "deprecation", "removal" })
@ConditionalOnThreading(Threading.PLATFORM)
ThreadPoolTaskScheduler taskScheduler(TaskSchedulerBuilder taskSchedulerBuilder,
ThreadPoolTaskScheduler taskScheduler(org.springframework.boot.task.TaskSchedulerBuilder taskSchedulerBuilder,
ObjectProvider<ThreadPoolTaskSchedulerBuilder> threadPoolTaskSchedulerBuilderProvider) {
ThreadPoolTaskSchedulerBuilder threadPoolTaskSchedulerBuilder = threadPoolTaskSchedulerBuilderProvider
.getIfUnique();
@@ -71,14 +69,14 @@ class TaskSchedulingConfigurations {
}
@Configuration(proxyBeanMethods = false)
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
static class TaskSchedulerBuilderConfiguration {
@Bean
@ConditionalOnMissingBean
TaskSchedulerBuilder taskSchedulerBuilder(TaskSchedulingProperties properties,
ObjectProvider<TaskSchedulerCustomizer> taskSchedulerCustomizers) {
TaskSchedulerBuilder builder = new TaskSchedulerBuilder();
org.springframework.boot.task.TaskSchedulerBuilder taskSchedulerBuilder(TaskSchedulingProperties properties,
ObjectProvider<org.springframework.boot.task.TaskSchedulerCustomizer> taskSchedulerCustomizers) {
org.springframework.boot.task.TaskSchedulerBuilder builder = new org.springframework.boot.task.TaskSchedulerBuilder();
builder = builder.poolSize(properties.getPool().getSize());
TaskSchedulingProperties.Shutdown shutdown = properties.getShutdown();
builder = builder.awaitTermination(shutdown.isAwaitTermination());
@@ -91,14 +89,15 @@ class TaskSchedulingConfigurations {
}
@Configuration(proxyBeanMethods = false)
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
static class ThreadPoolTaskSchedulerBuilderConfiguration {
@Bean
@ConditionalOnMissingBean({ TaskSchedulerBuilder.class, ThreadPoolTaskSchedulerBuilder.class })
@ConditionalOnMissingBean({ org.springframework.boot.task.TaskSchedulerBuilder.class,
ThreadPoolTaskSchedulerBuilder.class })
ThreadPoolTaskSchedulerBuilder threadPoolTaskSchedulerBuilder(TaskSchedulingProperties properties,
ObjectProvider<ThreadPoolTaskSchedulerCustomizer> threadPoolTaskSchedulerCustomizers,
ObjectProvider<TaskSchedulerCustomizer> taskSchedulerCustomizers) {
ObjectProvider<org.springframework.boot.task.TaskSchedulerCustomizer> taskSchedulerCustomizers) {
TaskSchedulingProperties.Shutdown shutdown = properties.getShutdown();
ThreadPoolTaskSchedulerBuilder builder = new ThreadPoolTaskSchedulerBuilder();
builder = builder.poolSize(properties.getPool().getSize());
@@ -111,7 +110,8 @@ class TaskSchedulingConfigurations {
return builder;
}
private ThreadPoolTaskSchedulerCustomizer adapt(TaskSchedulerCustomizer customizer) {
private ThreadPoolTaskSchedulerCustomizer adapt(
org.springframework.boot.task.TaskSchedulerCustomizer customizer) {
return customizer::customize;
}

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,13 +35,14 @@ import org.springframework.context.annotation.Scope;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.client.RestClient;
import org.springframework.web.client.RestClient.Builder;
/**
* {@link EnableAutoConfiguration Auto-configuration} for {@link RestClient}.
* <p>
* This will produce a {@link RestClient.Builder RestClient.Builder} bean with the
* {@code prototype} scope, meaning each injection point will receive a newly cloned
* instance of the builder.
* This will produce a {@link Builder RestClient.Builder} bean with the {@code prototype}
* scope, meaning each injection point will receive a newly cloned instance of the
* builder.
*
* @author Arjen Poutsma
* @author Moritz Halbritter

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.
@@ -23,7 +23,7 @@ import org.springframework.web.client.RestClient;
import org.springframework.web.client.RestClient.Builder;
/**
* Configure {@link RestClient.Builder} with sensible defaults.
* Configure {@link Builder RestClient.Builder} with sensible defaults.
*
* @author Moritz Halbritter
* @since 3.2.0
@@ -37,9 +37,9 @@ public class RestClientBuilderConfigurer {
}
/**
* Configure the specified {@link RestClient.Builder}. The builder can be further
* tuned and default settings can be overridden.
* @param builder the {@link RestClient.Builder} instance to configure
* Configure the specified {@link Builder RestClient.Builder}. The builder can be
* further tuned and default settings can be overridden.
* @param builder the {@link Builder RestClient.Builder} instance to configure
* @return the configured builder
*/
public RestClient.Builder configure(RestClient.Builder builder) {

View File

@@ -27,7 +27,6 @@ import graphql.schema.GraphQLObjectType;
import graphql.schema.GraphQLOutputType;
import graphql.schema.GraphQLSchema;
import graphql.schema.idl.RuntimeWiring;
import graphql.schema.visibility.DefaultGraphqlFieldVisibility;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -171,20 +170,13 @@ class GraphQlAutoConfigurationTests {
@Test
void fieldIntrospectionShouldBeEnabledByDefault() {
this.contextRunner.run((context) -> {
GraphQlSource graphQlSource = context.getBean(GraphQlSource.class);
GraphQLSchema schema = graphQlSource.schema();
assertThat(schema.getCodeRegistry().getFieldVisibility()).isInstanceOf(DefaultGraphqlFieldVisibility.class);
});
this.contextRunner.run((context) -> assertThat(Introspection.isEnabledJvmWide()).isTrue());
}
@Test
void shouldDisableFieldIntrospection() {
this.contextRunner.withPropertyValues("spring.graphql.schema.introspection.enabled:false").run((context) -> {
GraphQlSource graphQlSource = context.getBean(GraphQlSource.class);
GraphQLSchema schema = graphQlSource.schema();
assertThat(Introspection.isEnabledJvmWide()).isFalse();
});
this.contextRunner.withPropertyValues("spring.graphql.schema.introspection.enabled:false")
.run((context) -> assertThat(Introspection.isEnabledJvmWide()).isFalse());
}
@Test

View File

@@ -80,6 +80,7 @@ class TaskExecutionAutoConfigurationTests {
}
@Test
@SuppressWarnings("deprecation")
void shouldNotSupplyThreadPoolTaskExecutorBuilderIfCustomTaskExecutorBuilderIsPresent() {
this.contextRunner.withBean(TaskExecutorBuilder.class, TaskExecutorBuilder::new).run((context) -> {
assertThat(context).hasSingleBean(TaskExecutorBuilder.class);
@@ -164,6 +165,7 @@ class TaskExecutionAutoConfigurationTests {
}
@Test
@SuppressWarnings("deprecation")
void taskExecutorBuilderShouldUseTaskDecorator() {
this.contextRunner.withUserConfiguration(TaskDecoratorConfig.class).run((context) -> {
assertThat(context).hasSingleBean(TaskExecutorBuilder.class);
@@ -275,6 +277,7 @@ class TaskExecutionAutoConfigurationTests {
}
@Test
@SuppressWarnings("deprecation")
void taskExecutorBuilderShouldApplyCustomizer() {
this.contextRunner.withUserConfiguration(TaskExecutorCustomizerConfig.class).run((context) -> {
TaskExecutorCustomizer customizer = context.getBean(TaskExecutorCustomizer.class);
@@ -284,6 +287,7 @@ class TaskExecutionAutoConfigurationTests {
}
@Test
@SuppressWarnings("deprecation")
void threadPoolTaskExecutorBuilderShouldApplyCustomizer() {
this.contextRunner.withUserConfiguration(TaskExecutorCustomizerConfig.class).run((context) -> {
TaskExecutorCustomizer customizer = context.getBean(TaskExecutorCustomizer.class);
@@ -335,6 +339,7 @@ class TaskExecutionAutoConfigurationTests {
});
}
@SuppressWarnings("deprecation")
private ContextConsumer<AssertableApplicationContext> assertTaskExecutor(
Consumer<ThreadPoolTaskExecutor> taskExecutor) {
return (context) -> {
@@ -379,7 +384,8 @@ class TaskExecutionAutoConfigurationTests {
@Configuration(proxyBeanMethods = false)
static class CustomTaskExecutorBuilderConfig {
private final TaskExecutorBuilder taskExecutorBuilder = new TaskExecutorBuilder()
@SuppressWarnings("deprecation")
private final org.springframework.boot.task.TaskExecutorBuilder taskExecutorBuilder = new org.springframework.boot.task.TaskExecutorBuilder()
.threadNamePrefix("CustomTaskExecutorBuilderConfig-");
@Bean

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.
@@ -87,6 +87,7 @@ class TaskSchedulingAutoConfigurationTests {
}
@Test
@SuppressWarnings("deprecation")
void shouldNotSupplyThreadPoolTaskSchedulerBuilderIfCustomTaskSchedulerBuilderIsPresent() {
this.contextRunner.withUserConfiguration(SchedulingConfiguration.class)
.withBean(TaskSchedulerBuilder.class, TaskSchedulerBuilder::new)
@@ -155,7 +156,6 @@ class TaskSchedulingAutoConfigurationTests {
}
@Test
@SuppressWarnings("unchecked")
void simpleAsyncTaskSchedulerBuilderShouldApplyCustomizers() {
SimpleAsyncTaskSchedulerCustomizer customizer = (scheduler) -> {
};