Reduce warnings reported by Eclipse

Closes gh-41598
This commit is contained in:
Andy Wilkinson
2024-07-24 21:31:14 +01:00
parent f9f530ddaa
commit 5f666eec5b
31 changed files with 154 additions and 141 deletions

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.
@@ -30,7 +30,6 @@ import brave.context.slf4j.MDCScopeDecorator;
import brave.propagation.CurrentTraceContext.ScopeDecorator;
import brave.propagation.Propagation;
import brave.propagation.Propagation.Factory;
import brave.propagation.Propagation.KeyFactory;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.actuate.autoconfigure.tracing.TracingProperties.Baggage.Correlation;
@@ -102,7 +101,7 @@ class BravePropagationConfigurations {
return new Factory() {
@Override
public <K> Propagation<K> create(KeyFactory<K> keyFactory) {
public <K> Propagation<K> create(brave.propagation.Propagation.KeyFactory<K> keyFactory) {
return null;
}

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 brave.baggage.BaggagePropagation.FactoryBuilder;
import brave.baggage.BaggagePropagationConfig;
import brave.propagation.Propagation;
import brave.propagation.Propagation.Factory;
import brave.propagation.Propagation.KeyFactory;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@@ -54,7 +53,7 @@ class LocalBaggageFieldsTests {
private static FactoryBuilder createBuilder() {
return BaggagePropagation.newFactoryBuilder(new Factory() {
@Override
public <K> Propagation<K> create(KeyFactory<K> keyFactory) {
public <K> Propagation<K> create(brave.propagation.Propagation.KeyFactory<K> keyFactory) {
return null;
}
});

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.
@@ -48,7 +48,7 @@ abstract class ZipkinHttpSenderTests {
abstract Sender createSender();
@BeforeEach
void beforeEach() throws Exception {
void beforeEach() {
this.sender = createSender();
}

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.
@@ -72,7 +72,7 @@ class ZipkinWebClientSenderTests extends ZipkinHttpSenderTests {
@Override
@BeforeEach
void beforeEach() throws Exception {
void beforeEach() {
super.beforeEach();
clearResponses();
clearRequests();
@@ -175,10 +175,16 @@ class ZipkinWebClientSenderTests extends ZipkinHttpSenderTests {
assertThat(request).satisfies(assertions);
}
private static void clearRequests() throws InterruptedException {
private static void clearRequests() {
RecordedRequest request;
do {
request = mockBackEnd.takeRequest(0, TimeUnit.SECONDS);
try {
request = mockBackEnd.takeRequest(0, TimeUnit.SECONDS);
}
catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new RuntimeException(ex);
}
}
while (request != null);
}

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.
@@ -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;
@@ -48,7 +46,6 @@ class TaskExecutorConfigurations {
@Configuration(proxyBeanMethods = false)
@ConditionalOnMissingBean(Executor.class)
@SuppressWarnings("removal")
static class TaskExecutorConfiguration {
@Bean(name = { TaskExecutionAutoConfiguration.APPLICATION_TASK_EXECUTOR_BEAN_NAME,
@@ -62,7 +59,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();
@@ -81,11 +80,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());
@@ -103,14 +102,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();
@@ -130,7 +130,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;
@@ -169,20 +168,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

@@ -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.
@@ -79,6 +79,7 @@ class TaskExecutionAutoConfigurationTests {
}
@Test
@SuppressWarnings("deprecation")
void shouldNotSupplyThreadPoolTaskExecutorBuilderIfCustomTaskExecutorBuilderIsPresent() {
this.contextRunner.withBean(TaskExecutorBuilder.class, TaskExecutorBuilder::new).run((context) -> {
assertThat(context).hasSingleBean(TaskExecutorBuilder.class);
@@ -162,6 +163,7 @@ class TaskExecutionAutoConfigurationTests {
}
@Test
@SuppressWarnings("deprecation")
void taskExecutorBuilderShouldUseTaskDecorator() {
this.contextRunner.withUserConfiguration(TaskDecoratorConfig.class).run((context) -> {
assertThat(context).hasSingleBean(TaskExecutorBuilder.class);
@@ -273,6 +275,7 @@ class TaskExecutionAutoConfigurationTests {
}
@Test
@SuppressWarnings("deprecation")
void taskExecutorBuilderShouldApplyCustomizer() {
this.contextRunner.withUserConfiguration(TaskExecutorCustomizerConfig.class).run((context) -> {
TaskExecutorCustomizer customizer = context.getBean(TaskExecutorCustomizer.class);
@@ -282,6 +285,7 @@ class TaskExecutionAutoConfigurationTests {
}
@Test
@SuppressWarnings("deprecation")
void threadPoolTaskExecutorBuilderShouldApplyCustomizer() {
this.contextRunner.withUserConfiguration(TaskExecutorCustomizerConfig.class).run((context) -> {
TaskExecutorCustomizer customizer = context.getBean(TaskExecutorCustomizer.class);
@@ -333,6 +337,7 @@ class TaskExecutionAutoConfigurationTests {
});
}
@SuppressWarnings("deprecation")
private ContextConsumer<AssertableApplicationContext> assertTaskExecutor(
Consumer<ThreadPoolTaskExecutor> taskExecutor) {
return (context) -> {
@@ -377,7 +382,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) -> {
};

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2023-2023 the original author or authors.
* Copyright 2023-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,6 +37,7 @@ public class MyBean {
this.pulsarReaderFactory = pulsarReaderFactory;
}
@SuppressWarnings("unused")
public void someMethod() {
ReactiveMessageReaderBuilderCustomizer<String> readerBuilderCustomizer = (readerBuilder) -> readerBuilder
.topic("someTopic")

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,13 +29,13 @@ import org.springframework.boot.test.web.client.MockServerRestClientCustomizer;
import org.springframework.boot.test.web.client.MockServerRestTemplateCustomizer;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.web.client.RestClient;
import org.springframework.web.client.RestClient.Builder;
/**
* Annotation that can be applied to a test class to enable and configure
* auto-configuration of a single {@link MockRestServiceServer}. Only useful when a single
* call is made to {@link RestTemplateBuilder} or {@link RestClient.Builder}. If multiple
* {@link org.springframework.web.client.RestTemplate RestTemplates} or
* call is made to {@link RestTemplateBuilder} or {@link Builder RestClient.Builder}. If
* multiple {@link org.springframework.web.client.RestTemplate RestTemplates} or
* {@link org.springframework.web.client.RestClient RestClients} are in use, inject a
* {@link MockServerRestTemplateCustomizer} and use
* {@link MockServerRestTemplateCustomizer#getServer(org.springframework.web.client.RestTemplate)

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.
@@ -38,12 +38,12 @@ import org.springframework.stereotype.Component;
import org.springframework.test.context.BootstrapWith;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.web.client.RestClient;
import org.springframework.web.client.RestClient.Builder;
import org.springframework.web.client.RestTemplate;
/**
* Annotation for a Spring rest client test that focuses <strong>only</strong> on beans
* that use {@link RestTemplateBuilder} or {@link RestClient.Builder}.
* that use {@link RestTemplateBuilder} or {@link Builder RestClient.Builder}.
* <p>
* Using this annotation will disable full auto-configuration and instead apply only
* configuration relevant to rest client tests (i.e. Jackson or GSON auto-configuration

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.
@@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class ConditionReportApplicationContextFailureProcessorTests {
@Test
void loadFailureShouldPrintReport(CapturedOutput output) throws Exception {
void loadFailureShouldPrintReport(CapturedOutput output) {
SpringApplication application = new SpringApplication(TestConfig.class);
application.setWebApplicationType(WebApplicationType.NONE);
ConfigurableApplicationContext applicationContext = application.run();

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.
@@ -20,7 +20,6 @@ import java.util.Collections;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.mock.env.MockEnvironment;
@@ -148,11 +147,6 @@ class ObservabilityContextCustomizerFactoryTests {
return contextCustomizer;
}
private ApplicationContextInitializer<ConfigurableApplicationContext> applyCustomizer(
ContextCustomizer customizer) {
return (applicationContext) -> customizer.customizeContext(applicationContext, null);
}
private void assertThatTracingIsDisabled(ConfigurableApplicationContext context) {
assertThat(context.getEnvironment().getProperty("management.tracing.enabled")).isEqualTo("false");
}

View File

@@ -30,9 +30,10 @@ import org.springframework.test.web.client.RequestExpectationManager;
import org.springframework.test.web.client.SimpleRequestExpectationManager;
import org.springframework.util.Assert;
import org.springframework.web.client.RestClient;
import org.springframework.web.client.RestClient.Builder;
/**
* {@link RestClientCustomizer} that can be applied to {@link RestClient.Builder}
* {@link RestClientCustomizer} that can be applied to {@link Builder RestClient.Builder}
* instances to add {@link MockRestServiceServer} support.
* <p>
* Typically applied to an existing builder before it is used, for example:

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.
@@ -18,9 +18,6 @@ package org.springframework.boot.configurationsample.record;
import org.springframework.boot.configurationsample.ConfigurationProperties;
/**
* @author Moritz Halbritter
*/
@ConfigurationProperties("record-with-getter")
public record RecordWithGetter(String alpha) {

View File

@@ -32,7 +32,6 @@ public final class GradleVersions {
private GradleVersions() {
}
@SuppressWarnings("UnstableApiUsage")
public static List<String> allCompatible() {
if (isJavaVersion(JavaVersion.VERSION_20)) {
return Arrays.asList("8.1.1", "8.9");

View File

@@ -264,6 +264,12 @@ public abstract class Packager {
}
}
/**
* Writes a signature file if necessary for the given {@code writtenLibraries}.
* @param writtenLibraries the libraries
* @param writer the writer to use to write the signature file if necessary
* @throws IOException if a failure occurs when writing the signature file
*/
protected void writeSignatureFileIfNecessary(Map<String, Library> writtenLibraries, AbstractJarWriter writer)
throws IOException {
}

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.
@@ -33,44 +33,49 @@ class ByteArrayDataBlockTests {
@Test
void sizeReturnsByteArrayLength() throws Exception {
ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES);
assertThat(dataBlock.size()).isEqualTo(this.BYTES.length);
try (ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES)) {
assertThat(dataBlock.size()).isEqualTo(this.BYTES.length);
}
}
@Test
void readPutsBytes() throws Exception {
ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES);
ByteBuffer dst = ByteBuffer.allocate(8);
int result = dataBlock.read(dst, 0);
assertThat(result).isEqualTo(8);
assertThat(dst.array()).containsExactly(this.BYTES);
try (ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES)) {
ByteBuffer dst = ByteBuffer.allocate(8);
int result = dataBlock.read(dst, 0);
assertThat(result).isEqualTo(8);
assertThat(dst.array()).containsExactly(this.BYTES);
}
}
@Test
void readWhenLessBytesThanRemainingInBufferPutsBytes() throws Exception {
ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES);
ByteBuffer dst = ByteBuffer.allocate(9);
int result = dataBlock.read(dst, 0);
assertThat(result).isEqualTo(8);
assertThat(dst.array()).containsExactly(0, 1, 2, 3, 4, 5, 6, 7, 0);
try (ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES)) {
ByteBuffer dst = ByteBuffer.allocate(9);
int result = dataBlock.read(dst, 0);
assertThat(result).isEqualTo(8);
assertThat(dst.array()).containsExactly(0, 1, 2, 3, 4, 5, 6, 7, 0);
}
}
@Test
void readWhenLessRemainingInBufferThanLengthPutsBytes() throws Exception {
ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES);
ByteBuffer dst = ByteBuffer.allocate(7);
int result = dataBlock.read(dst, 0);
assertThat(result).isEqualTo(7);
assertThat(dst.array()).containsExactly(0, 1, 2, 3, 4, 5, 6);
try (ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES)) {
ByteBuffer dst = ByteBuffer.allocate(7);
int result = dataBlock.read(dst, 0);
assertThat(result).isEqualTo(7);
assertThat(dst.array()).containsExactly(0, 1, 2, 3, 4, 5, 6);
}
}
@Test
void readWhenHasPosOffsetReadsBytes() throws Exception {
ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES);
ByteBuffer dst = ByteBuffer.allocate(3);
int result = dataBlock.read(dst, 4);
assertThat(result).isEqualTo(3);
assertThat(dst.array()).containsExactly(4, 5, 6);
try (ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES)) {
ByteBuffer dst = ByteBuffer.allocate(3);
int result = dataBlock.read(dst, 4);
assertThat(result).isEqualTo(3);
assertThat(dst.array()).containsExactly(4, 5, 6);
}
}
}

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.
@@ -20,7 +20,6 @@ import java.net.InetAddress;
import org.springframework.boot.ssl.SslBundles;
import org.springframework.boot.web.server.Ssl;
import org.springframework.boot.web.server.SslStoreProvider;
import org.springframework.util.unit.DataSize;
/**
@@ -73,7 +72,7 @@ public interface ConfigurableRSocketServerFactory {
*/
@SuppressWarnings("removal")
@Deprecated(since = "3.1.0", forRemoval = true)
void setSslStoreProvider(SslStoreProvider sslStoreProvider);
void setSslStoreProvider(org.springframework.boot.web.server.SslStoreProvider sslStoreProvider);
/**
* Sets an SSL bundle that can be used to get SSL configuration.

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

@@ -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.
@@ -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