Merge branch '4.0.x' into 4.1.x

Closes gh-51599
This commit is contained in:
Andy Wilkinson
2026-09-07 08:26:42 +01:00
149 changed files with 5 additions and 243 deletions
@@ -342,8 +342,7 @@ public abstract class EndpointDiscoverer<E extends ExposableEndpoint<O>, O exten
return isFilterMatch(filter, getFilterEndpoint(endpointBean));
}
// Doesn't detect lambda with correct nullability
@SuppressWarnings({ "unchecked", "NullAway" })
@SuppressWarnings("unchecked")
private boolean isFilterMatch(EndpointFilter<E> filter, E endpoint) {
Boolean result = LambdaSafe.callback(EndpointFilter.class, filter, endpoint)
.withLogger(EndpointDiscoverer.class)
@@ -362,8 +361,7 @@ public abstract class EndpointDiscoverer<E extends ExposableEndpoint<O>, O exten
return false;
}
// Doesn't detect lambda with correct nullability
@SuppressWarnings({ "unchecked", "NullAway" })
@SuppressWarnings("unchecked")
private boolean isFilterMatch(OperationFilter<O> filter, Operation operation, EndpointId endpointId,
Access defaultAccess) {
Boolean result = LambdaSafe.callback(OperationFilter.class, filter, operation)
@@ -42,7 +42,6 @@ class EndpointIdTests {
}
@Test
@SuppressWarnings("NullAway") // Test null check
void ofWhenEmptyThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> EndpointId.of(""))
.withMessage("'value' must not be empty");
@@ -51,11 +51,9 @@ import static org.mockito.BDDMockito.then;
class CachingOperationInvokerAdvisorTests {
@Mock
@SuppressWarnings("NullAway.Init")
private OperationInvoker invoker;
@Mock
@SuppressWarnings("NullAway.Init")
private Function<EndpointId, @Nullable Long> timeToLive;
private CachingOperationInvokerAdvisor advisor;
@@ -59,11 +59,9 @@ class JmxEndpointExporterTests {
private final List<ExposableJmxEndpoint> endpoints = new ArrayList<>();
@Mock
@SuppressWarnings("NullAway.Init")
private MBeanServer mBeanServer;
@Spy
@SuppressWarnings("NullAway.Init")
private EndpointObjectNameFactory objectNameFactory = new TestEndpointObjectNameFactory();
private JmxEndpointExporter exporter;
@@ -58,15 +58,12 @@ import static org.mockito.Mockito.mock;
class ServletEndpointRegistrarTests {
@Mock
@SuppressWarnings("NullAway.Init")
private ServletContext servletContext;
@Mock
@SuppressWarnings("NullAway.Init")
private ServletRegistration.Dynamic servletDynamic;
@Mock
@SuppressWarnings("NullAway.Init")
private FilterRegistration.Dynamic filterDynamic;
@Test
@@ -45,11 +45,9 @@ import static org.mockito.Mockito.mock;
class RabbitHealthIndicatorTests {
@Mock
@SuppressWarnings("NullAway.Init")
private RabbitTemplate rabbitTemplate;
@Mock
@SuppressWarnings("NullAway.Init")
private Channel channel;
@Test
@@ -69,8 +69,7 @@ public class CacheMetricsRegistrar {
return false;
}
// Lambda isn't detected with the correct nullability
@SuppressWarnings({ "unchecked", "NullAway" })
@SuppressWarnings("unchecked")
private @Nullable MeterBinder getMeterBinder(Cache cache, Tags tags) {
Tags cacheTags = tags.and(getAdditionalTags(cache));
return LambdaSafe.callbacks(CacheMeterBinderProvider.class, this.binderProviders, cache)
@@ -42,7 +42,6 @@ import static org.mockito.Mockito.mock;
class JCacheCacheMeterBinderProviderTests {
@Mock
@SuppressWarnings("NullAway.Init")
private javax.cache.Cache<Object, Object> nativeCache;
@Test
@@ -48,11 +48,9 @@ import static org.mockito.BDDMockito.given;
class SecurityInterceptorTests {
@Mock
@SuppressWarnings("NullAway.Init")
private TokenValidator tokenValidator;
@Mock
@SuppressWarnings("NullAway.Init")
private SecurityService securityService;
private SecurityInterceptor interceptor;
@@ -60,7 +60,6 @@ class TokenValidatorTests {
private static final byte[] DOT = ".".getBytes();
@Mock
@SuppressWarnings("NullAway.Init")
private SecurityService securityService;
private TokenValidator tokenValidator;
@@ -46,11 +46,9 @@ import static org.mockito.BDDMockito.then;
class SecurityInterceptorTests {
@Mock
@SuppressWarnings("NullAway.Init")
private TokenValidator tokenValidator;
@Mock
@SuppressWarnings("NullAway.Init")
private SecurityService securityService;
private SecurityInterceptor interceptor;
@@ -59,7 +59,6 @@ class TokenValidatorTests {
private static final byte[] DOT = ".".getBytes();
@Mock
@SuppressWarnings("NullAway.Init")
private SecurityService securityService;
private TokenValidator tokenValidator;
@@ -31,12 +31,10 @@ public class Country implements Serializable {
@Id
@GeneratedValue
@SuppressWarnings("NullAway.Init")
private Long id;
@Audited
@Column
@SuppressWarnings("NullAway.Init")
private String name;
public Long getId() {
@@ -52,7 +52,6 @@ abstract class AbstractDevToolsIntegrationTests {
protected final JvmLauncher javaLauncher = new JvmLauncher();
@TempDir
@SuppressWarnings("NullAway.Init")
protected static File temp;
private @Nullable LaunchedApplication launchedApplication;
@@ -32,7 +32,6 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
class TriggerFileFilterTests {
@TempDir
@SuppressWarnings("NullAway.Init")
File tempDir;
@Test
@@ -47,15 +47,12 @@ import static org.mockito.Mockito.never;
class ClassPathFileChangeListenerTests {
@Mock
@SuppressWarnings("NullAway.Init")
private ApplicationEventPublisher eventPublisher;
@Mock
@SuppressWarnings("NullAway.Init")
private ClassPathRestartStrategy restartStrategy;
@Mock
@SuppressWarnings("NullAway.Init")
private FileSystemWatcher fileSystemWatcher;
@Test
@@ -34,7 +34,6 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
class ChangedFileTests {
@TempDir
@SuppressWarnings("NullAway.Init")
File tempDir;
@Test
@@ -38,7 +38,6 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
class DirectorySnapshotTests {
@TempDir
@SuppressWarnings("NullAway.Init")
File tempDir;
private File directory;
@@ -42,7 +42,6 @@ class FileSnapshotTests {
private static final long MODIFIED = new Date().getTime() - TimeUnit.DAYS.toMillis(10);
@TempDir
@SuppressWarnings("NullAway.Init")
File tempDir;
@Test
@@ -54,7 +54,6 @@ class FileSystemWatcherTests {
private final List<Set<ChangedFiles>> changes = Collections.synchronizedList(new ArrayList<>());
@TempDir
@SuppressWarnings("NullAway.Init")
File tempDir;
@BeforeEach
@@ -50,27 +50,21 @@ class DelayedLiveReloadTriggerTests {
private static final String URL = "http://localhost:8080";
@Mock
@SuppressWarnings("NullAway.Init")
private OptionalLiveReloadServer liveReloadServer;
@Mock
@SuppressWarnings("NullAway.Init")
private ClientHttpRequestFactory requestFactory;
@Mock
@SuppressWarnings("NullAway.Init")
private ClientHttpRequest errorRequest;
@Mock
@SuppressWarnings("NullAway.Init")
private ClientHttpRequest okRequest;
@Mock
@SuppressWarnings("NullAway.Init")
private ClientHttpResponse errorResponse;
@Mock
@SuppressWarnings("NullAway.Init")
private ClientHttpResponse okResponse;
private DelayedLiveReloadTrigger trigger;
@@ -54,11 +54,9 @@ class HttpHeaderInterceptorTests {
private byte[] body;
@Mock
@SuppressWarnings("NullAway.Init")
private ClientHttpRequestExecution execution;
@Mock
@SuppressWarnings("NullAway.Init")
private ClientHttpResponse response;
private MockHttpServletRequest httpRequest;
@@ -51,11 +51,9 @@ import static org.mockito.Mockito.mock;
class DispatcherFilterTests {
@Mock
@SuppressWarnings("NullAway.Init")
private Dispatcher dispatcher;
@Mock
@SuppressWarnings("NullAway.Init")
private FilterChain chain;
private DispatcherFilter filter;
@@ -52,7 +52,6 @@ import static org.mockito.Mockito.withSettings;
class DispatcherTests {
@Mock
@SuppressWarnings("NullAway.Init")
private AccessManager accessManager;
private final MockHttpServletResponse response = new MockHttpServletResponse();
@@ -43,7 +43,6 @@ import static org.assertj.core.api.Assertions.assertThat;
class ChangeableUrlsTests {
@TempDir
@SuppressWarnings("NullAway.Init")
File tempDir;
@Test
@@ -40,21 +40,18 @@ class ClassLoaderFileTests {
}
@Test
@SuppressWarnings("NullAway") // Test null check
void addedContentsMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new ClassLoaderFile(Kind.ADDED, null))
.withMessageContaining("'contents' must not be null");
}
@Test
@SuppressWarnings("NullAway") // Test null check
void modifiedContentsMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new ClassLoaderFile(Kind.MODIFIED, null))
.withMessageContaining("'contents' must not be null");
}
@Test
@SuppressWarnings("NullAway") // Test null check
void deletedContentsMustBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new ClassLoaderFile(Kind.DELETED, new byte[10]))
.withMessageContaining("'contents' must be null");
@@ -52,7 +52,6 @@ import static org.mockito.BDDMockito.then;
class HttpRestartServerTests {
@Mock
@SuppressWarnings("NullAway.Init")
private RestartServer delegate;
private HttpRestartServer server;
@@ -35,11 +35,9 @@ import static org.assertj.core.api.Assertions.assertThat;
class AutoConfiguredHealthCheckedGrpcComponentTests {
@Mock
@SuppressWarnings("NullAway.Init")
private StatusAggregator statusAggregator;
@Mock
@SuppressWarnings("NullAway.Init")
private StatusMapper statusMapper;
@Test
@@ -41,7 +41,6 @@ import static org.mockito.BDDMockito.given;
class AvailabilityStateHealthIndicatorTests {
@Mock
@SuppressWarnings("NullAway.Init")
private ApplicationAvailability applicationAvailability;
@Test
@@ -46,7 +46,6 @@ class DiskSpaceHealthIndicatorTests {
private static final DataSize TOTAL_SPACE = DataSize.ofKilobytes(10);
@Mock
@SuppressWarnings("NullAway.Init")
private File fileMock;
private HealthIndicator healthIndicator;
@@ -45,19 +45,15 @@ import static org.mockito.Mockito.mock;
class AutoConfiguredHealthEndpointGroupTests {
@Mock
@SuppressWarnings("NullAway.Init")
private StatusAggregator statusAggregator;
@Mock
@SuppressWarnings("NullAway.Init")
private HttpCodeStatusMapper httpCodeStatusMapper;
@Mock
@SuppressWarnings("NullAway.Init")
private SecurityContext securityContext;
@Mock
@SuppressWarnings("NullAway.Init")
private Principal principal;
@Test
@@ -56,7 +56,6 @@ class HibernatePropertiesTests {
.withUserConfiguration(TestConfiguration.class);
@Mock
@SuppressWarnings("NullAway.Init")
private Supplier<String> ddlAutoSupplier;
@Test
@@ -31,12 +31,10 @@ public class Country implements Serializable {
@Id
@GeneratedValue
@SuppressWarnings("NullAway.Init")
private Long id;
@Audited
@Column
@SuppressWarnings("NullAway.Init")
private String name;
public Long getId() {
@@ -65,7 +65,6 @@ public class DataSourcePoolMetrics implements MeterBinder {
}
@Override
@SuppressWarnings("NullAway") // Lambda isn't detected with the correct nullability
public void bindTo(MeterRegistry registry) {
if (this.metadataProvider.getDataSourcePoolMetadata(this.dataSource) != null) {
bindPoolMetadata(registry, "active",
@@ -38,31 +38,24 @@ import static org.mockito.BDDMockito.given;
class CompositeDataSourcePoolMetadataProviderTests {
@Mock
@SuppressWarnings("NullAway.Init")
private DataSourcePoolMetadataProvider firstProvider;
@Mock
@SuppressWarnings("NullAway.Init")
private DataSourcePoolMetadata first;
@Mock
@SuppressWarnings("NullAway.Init")
private DataSource firstDataSource;
@Mock
@SuppressWarnings("NullAway.Init")
private DataSourcePoolMetadataProvider secondProvider;
@Mock
@SuppressWarnings("NullAway.Init")
private DataSourcePoolMetadata second;
@Mock
@SuppressWarnings("NullAway.Init")
private DataSource secondDataSource;
@Mock
@SuppressWarnings("NullAway.Init")
private DataSource unknownDataSource;
@BeforeEach
@@ -43,15 +43,12 @@ import static org.mockito.BDDMockito.then;
class TestEntityManagerTests {
@Mock
@SuppressWarnings("NullAway.Init")
private EntityManagerFactory entityManagerFactory;
@Mock
@SuppressWarnings("NullAway.Init")
private EntityManager entityManager;
@Mock
@SuppressWarnings("NullAway.Init")
private PersistenceUnitUtil persistenceUnitUtil;
private TestEntityManager testEntityManager;
@@ -1447,7 +1447,6 @@ public class KafkaProperties {
return properties;
}
@SuppressWarnings("NullAway") // Doesn't detect lambda with correct nullability
private void validate() {
MutuallyExclusiveConfigurationPropertiesException.throwIfMultipleMatchingValuesIn((entries) -> {
entries.put("spring.kafka.ssl.key-store-key", getKeyStoreKey());
@@ -67,23 +67,18 @@ class MeterRegistryPostProcessorTests {
private final List<MeterBinder> binders = new ArrayList<>();
@Mock
@SuppressWarnings("NullAway.Init")
private MeterRegistryCustomizer<MeterRegistry> mockCustomizer;
@Mock
@SuppressWarnings("NullAway.Init")
private MeterFilter mockFilter;
@Mock
@SuppressWarnings("NullAway.Init")
private MeterBinder mockBinder;
@Mock
@SuppressWarnings("NullAway.Init")
private MeterRegistry mockRegistry;
@Mock
@SuppressWarnings("NullAway.Init")
private Config mockConfig;
private final ApplicationContext meterRegistryCloserContext = mock(ApplicationContext.class);
@@ -50,21 +50,17 @@ import static org.mockito.Mockito.never;
class PrometheusPushGatewayManagerTests {
@Mock
@SuppressWarnings("NullAway.Init")
private PushGateway pushGateway;
@Mock
@SuppressWarnings("NullAway.Init")
private TaskScheduler scheduler;
private final Duration pushRate = Duration.ofSeconds(1);
@Captor
@SuppressWarnings("NullAway.Init")
private ArgumentCaptor<Runnable> task;
@Mock
@SuppressWarnings("NullAway.Init")
private ScheduledFuture<Object> future;
@Test
@@ -60,7 +60,6 @@ class SslServerCustomizerTests {
@Test
@WithPackageResources({ "1.key", "1.crt" })
@SuppressWarnings("NullAway") // Test null check
void getSslProviderReturnsDefaultWhenServerNameIsNull() {
SslBundle defaultBundle = createBundle("1.key", "1.crt");
SslServerCustomizer customizer = new SslServerCustomizer(null, Ssl.ClientAuth.NONE, defaultBundle,
@@ -63,7 +63,6 @@ class NettyReactiveWebServerFactoryCustomizerTests {
private NettyReactiveWebServerFactoryCustomizer customizer;
@Captor
@SuppressWarnings("NullAway.Init")
private ArgumentCaptor<NettyServerCustomizer> customizerCaptor;
@BeforeEach
@@ -55,7 +55,6 @@ class RootUriRequestExpectationManagerTests {
private final String uri = "https://example.com";
@Mock
@SuppressWarnings("NullAway.Init")
private RequestExpectationManager delegate;
private RootUriRequestExpectationManager manager;
@@ -87,11 +87,9 @@ class RestTemplateBuilderTests {
private final RestTemplateBuilder builder = new RestTemplateBuilder();
@Mock
@SuppressWarnings("NullAway.Init")
private HttpMessageConverter<Object> messageConverter;
@Mock
@SuppressWarnings("NullAway.Init")
private ClientHttpRequestInterceptor interceptor;
@Test
@@ -49,7 +49,6 @@ class RootUriTemplateHandlerTests {
private URI uri;
@Mock
@SuppressWarnings("NullAway.Init")
public UriTemplateHandler delegate;
public UriTemplateHandler handler;
@@ -52,15 +52,12 @@ class AutoConfiguredRestClientSslTests {
.withConnectTimeout(Duration.ofSeconds(30));
@Mock
@SuppressWarnings("NullAway.Init")
private SslBundles sslBundles;
@Mock
@SuppressWarnings("NullAway.Init")
private ClientHttpRequestFactoryBuilder<ClientHttpRequestFactory> factoryBuilder;
@Mock
@SuppressWarnings("NullAway.Init")
private ClientHttpRequestFactory factory;
private AutoConfiguredRestClientSsl restClientSsl;
@@ -281,7 +281,6 @@ class NettyRSocketServerFactoryTests {
@Test
@WithPackageResources({ "test-cert.pem", "test-key.pem" })
@SuppressWarnings("NullAway") // Test null check
void websocketTransportSslProviderReturnsDefaultWhenServerNameIsNull() {
SslBundle defaultBundle = createBundle("test-cert.pem", "test-key.pem");
NettyRSocketServerFactory.HttpServerSslCustomizer customizer = new NettyRSocketServerFactory.HttpServerSslCustomizer(
@@ -68,7 +68,6 @@ class DatabaseInitializationDependencyConfigurerTests {
private final ConfigurableEnvironment environment = new MockEnvironment();
@TempDir
@SuppressWarnings("NullAway.Init")
File temp;
@BeforeEach
@@ -45,7 +45,6 @@ import static org.assertj.core.api.Assertions.assertThat;
class TomcatEmbeddedWebappClassLoaderTests {
@TempDir
@SuppressWarnings("NullAway.Init")
File tempDir;
@Test
@@ -46,7 +46,6 @@ class WebServerFactoryCustomizerBeanPostProcessorTests {
private final WebServerFactoryCustomizerBeanPostProcessor processor = new WebServerFactoryCustomizerBeanPostProcessor();
@Mock
@SuppressWarnings("NullAway.Init")
private ListableBeanFactory beanFactory;
@BeforeEach
@@ -44,7 +44,6 @@ import static org.mockito.Mockito.mock;
class WebServerPortFileWriterTests {
@TempDir
@SuppressWarnings("NullAway.Init")
File tempDir;
@BeforeEach
@@ -40,7 +40,6 @@ class DocumentRootTests {
private static final Log logger = LogFactory.getLog(DocumentRootTests.class);
@TempDir
@SuppressWarnings("NullAway.Init")
File tempDir;
private final DocumentRoot documentRoot = new DocumentRoot(logger);
@@ -47,7 +47,6 @@ import static org.assertj.core.api.Assertions.assertThatNoException;
class StaticResourceJarsTests {
@TempDir
@SuppressWarnings("NullAway.Init")
File tempDir;
@Test
@@ -60,7 +60,6 @@ class MockWebEnvironmentServletComponentScanIntegrationTests {
private @Nullable AnnotationConfigServletWebApplicationContext context;
@TempDir
@SuppressWarnings("NullAway.Init")
File temp;
@AfterEach
@@ -58,7 +58,6 @@ class ServletComponentScanIntegrationTests {
private @Nullable AnnotationConfigServletWebServerApplicationContext context;
@TempDir
@SuppressWarnings("NullAway.Init")
File temp;
@AfterEach
@@ -102,7 +102,6 @@ class ServletWebServerApplicationContextTests {
private final ServletWebServerApplicationContext context = new ServletWebServerApplicationContext();
@Captor
@SuppressWarnings("NullAway.Init")
private ArgumentCaptor<Filter> filterCaptor;
@AfterEach
@@ -84,7 +84,6 @@ class WebFluxManagementChildContextConfigurationIntegrationTests {
.withPropertyValues("server.port=0", "management.server.port=0", "management.endpoints.web.exposure.include=*");
@TempDir
@SuppressWarnings("NullAway.Init")
Path temp;
@Test
@@ -83,7 +83,6 @@ class WebMvcEndpointChildContextConfigurationIntegrationTests {
"spring.web.error.include-binding-errors=always");
@TempDir
@SuppressWarnings("NullAway.Init")
Path temp;
@Test // gh-17938
@@ -62,7 +62,6 @@ class DefaultErrorViewResolverTests {
private DefaultErrorViewResolver resolver;
@Mock
@SuppressWarnings("NullAway.Init")
private TemplateAvailabilityProvider templateAvailabilityProvider;
private Resources resourcesProperties;
@@ -63,11 +63,9 @@ class WebServiceTemplateBuilderTests {
private final WebServiceTemplateBuilder builder = new WebServiceTemplateBuilder();
@Mock
@SuppressWarnings("NullAway.Init")
private WebServiceMessageSender messageSender;
@Mock
@SuppressWarnings("NullAway.Init")
private ClientInterceptor interceptor;
@Test