From dac18a3ff1e9516d2d900ffdff5af6939512da3c Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Fri, 24 May 2024 13:29:21 +0200 Subject: [PATCH] Clean up warnings in Gradle build --- .../aop/aspectj/annotation/AspectProxyFactoryTests.java | 8 ++++---- .../http/converter/FormHttpMessageConverterTests.java | 3 ++- .../RequestAttributesThreadLocalAccessorTests.java | 4 ++-- .../server/reactive/bootstrap/ReactorHttpsServer.java | 7 +++++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java index 1b3557eae2d..9e45538c713 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java @@ -41,8 +41,7 @@ class AspectProxyFactoryTests { @Test void testWithNonAspect() { AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean()); - assertThatIllegalArgumentException().isThrownBy(() -> - proxyFactory.addAspect(TestBean.class)); + assertThatIllegalArgumentException().isThrownBy(() -> proxyFactory.addAspect(TestBean.class)); } @Test @@ -78,8 +77,7 @@ class AspectProxyFactoryTests { @Test void testWithInstanceWithNonAspect() { AspectJProxyFactory pf = new AspectJProxyFactory(); - assertThatIllegalArgumentException().isThrownBy(() -> - pf.addAspect(new TestBean())); + assertThatIllegalArgumentException().isThrownBy(() -> pf.addAspect(new TestBean())); } @Test @@ -119,6 +117,7 @@ class AspectProxyFactoryTests { } @Test // SPR-13328 + @SuppressWarnings("unchecked") public void testProxiedVarargsWithEnumArray() { AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean()); proxyFactory.addAspect(LoggingAspectOnVarargs.class); @@ -127,6 +126,7 @@ class AspectProxyFactoryTests { } @Test // SPR-13328 + @SuppressWarnings("unchecked") public void testUnproxiedVarargsWithEnumArray() { AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean()); proxyFactory.addAspect(LoggingAspectOnSetter.class); diff --git a/spring-web/src/test/java/org/springframework/http/converter/FormHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/FormHttpMessageConverterTests.java index 43a8c91ecad..7a30dae8ace 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/FormHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/FormHttpMessageConverterTests.java @@ -119,6 +119,7 @@ class FormHttpMessageConverterTests { } @Test + @SuppressWarnings("unchecked") void readFormMultiValue() throws Exception { String body = "name+1=value+1&name+2=value+2%2B1&name+2=value+2%2B2&name+3"; MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes(StandardCharsets.ISO_8859_1)); @@ -134,7 +135,7 @@ class FormHttpMessageConverterTests { } @Test - @SuppressWarnings("rawtypes") + @SuppressWarnings({ "rawtypes", "unchecked" }) void readFormSingleValue() throws Exception { String body = "name+1=value+1&name+2=value+2%2B1&name+2=value+2%2B2&name+3"; MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes(StandardCharsets.ISO_8859_1)); diff --git a/spring-web/src/test/java/org/springframework/web/context/request/RequestAttributesThreadLocalAccessorTests.java b/spring-web/src/test/java/org/springframework/web/context/request/RequestAttributesThreadLocalAccessorTests.java index e0228291c7b..86e8438a0ec 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/RequestAttributesThreadLocalAccessorTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/RequestAttributesThreadLocalAccessorTests.java @@ -58,7 +58,6 @@ class RequestAttributesThreadLocalAccessorTests { @MethodSource @SuppressWarnings({ "try", "unused" }) void propagation(RequestAttributes previousRequest, RequestAttributes currentRequest) throws Exception { - ContextSnapshot snapshot = getSnapshotFor(currentRequest); AtomicReference requestInScope = new AtomicReference<>(); @@ -80,6 +79,7 @@ class RequestAttributesThreadLocalAccessorTests { } @Test + @SuppressWarnings("try") void accessAfterRequestMarkedCompleted() { MockHttpServletRequest servletRequest = new MockHttpServletRequest(); servletRequest.setAttribute("k1", "v1"); @@ -100,8 +100,8 @@ class RequestAttributesThreadLocalAccessorTests { } @Test + @SuppressWarnings("try") void accessBeforeRequestMarkedCompleted() { - MockHttpServletRequest servletRequest = new MockHttpServletRequest(); ServletRequestAttributes previous = new ServletRequestAttributes(servletRequest, new MockHttpServletResponse()); diff --git a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/ReactorHttpsServer.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/ReactorHttpsServer.java index 7db445489c6..66e23ce216d 100644 --- a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/ReactorHttpsServer.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/ReactorHttpsServer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-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. @@ -19,9 +19,11 @@ package org.springframework.web.testfixture.http.server.reactive.bootstrap; import java.net.InetSocketAddress; import java.util.concurrent.atomic.AtomicReference; +import io.netty.handler.ssl.SslContextBuilder; import io.netty.handler.ssl.util.SelfSignedCertificate; import reactor.netty.DisposableServer; import reactor.netty.http.Http11SslContextSpec; +import reactor.netty.tcp.SslProvider.GenericSslContextSpec; import org.springframework.http.server.reactive.ReactorHttpHandlerAdapter; @@ -40,7 +42,8 @@ public class ReactorHttpsServer extends AbstractHttpServer { @Override protected void initServer() throws Exception { SelfSignedCertificate cert = new SelfSignedCertificate(); - Http11SslContextSpec http11SslContextSpec = Http11SslContextSpec.forServer(cert.certificate(), cert.privateKey()); + GenericSslContextSpec http11SslContextSpec = + Http11SslContextSpec.forServer(cert.certificate(), cert.privateKey()); this.reactorHandler = createHttpHandlerAdapter(); this.reactorServer = reactor.netty.http.server.HttpServer.create()