Browse Source

Suppress warnings

pull/29155/head
Sam Brannen 4 years ago
parent
commit
911d1f2dea
  1. 3
      spring-context/src/test/java/org/springframework/context/annotation/Gh29105Tests.java
  2. 3
      spring-core/src/main/java/org/springframework/aot/hint/ReflectionHints.java
  3. 4
      spring-web/src/test/java/org/springframework/http/client/support/InterceptingHttpAccessorTests.java
  4. 1
      spring-web/src/test/java/org/springframework/http/server/reactive/AsyncIntegrationTests.java
  5. 1
      spring-web/src/test/java/org/springframework/http/server/reactive/CookieIntegrationTests.java
  6. 3
      spring-web/src/test/java/org/springframework/http/server/reactive/EchoHandlerIntegrationTests.java
  7. 3
      spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java
  8. 3
      spring-web/src/test/java/org/springframework/http/server/reactive/MultipartIntegrationTests.java
  9. 3
      spring-web/src/test/java/org/springframework/http/server/reactive/RandomHandlerIntegrationTests.java
  10. 1
      spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestIntegrationTests.java
  11. 3
      spring-web/src/test/java/org/springframework/http/server/reactive/WriteOnlyHandlerIntegrationTests.java
  12. 1
      spring-web/src/test/java/org/springframework/http/server/reactive/ZeroCopyIntegrationTests.java
  13. 1
      spring-web/src/test/java/org/springframework/web/client/RestTemplateTests.java
  14. 4
      spring-webflux/src/test/java/org/springframework/web/reactive/result/SimpleUrlHandlerMappingIntegrationTests.java
  15. 4
      spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ContextPathIntegrationTests.java
  16. 3
      spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingViewResolutionIntegrationTests.java

3
spring-context/src/test/java/org/springframework/context/annotation/Gh29105Tests.java

@ -47,6 +47,8 @@ public class Gh29105Tests { @@ -47,6 +47,8 @@ public class Gh29105Tests {
List<Class<?>> orderedTypes = child.getBeanProvider(MyService.class)
.orderedStream().map(Object::getClass).collect(Collectors.toList());
assertThat(orderedTypes).containsExactly(CustomService.class, DefaultService.class);
parent.close();
child.close();
}
@ -78,4 +80,5 @@ public class Gh29105Tests { @@ -78,4 +80,5 @@ public class Gh29105Tests {
}
}
}

3
spring-core/src/main/java/org/springframework/aot/hint/ReflectionHints.java

@ -210,6 +210,7 @@ public class ReflectionHints { @@ -210,6 +210,7 @@ public class ReflectionHints {
* @deprecated in favor of {@link #registerConstructor(Constructor, ExecutableMode)}
*/
@Deprecated
@SuppressWarnings("deprecation")
public ReflectionHints registerConstructor(Constructor<?> constructor, Consumer<ExecutableHint.Builder> constructorHint) {
return registerType(TypeReference.of(constructor.getDeclaringClass()),
typeHint -> typeHint.withConstructor(mapParameters(constructor), constructorHint));
@ -247,7 +248,7 @@ public class ReflectionHints { @@ -247,7 +248,7 @@ public class ReflectionHints {
* @deprecated in favor of {@link #registerMethod(Method, ExecutableMode)}
*/
@Deprecated
@SuppressWarnings("deprecation")
public ReflectionHints registerMethod(Method method, Consumer<ExecutableHint.Builder> methodHint) {
return registerType(TypeReference.of(method.getDeclaringClass()),
typeHint -> typeHint.withMethod(method.getName(), mapParameters(method), methodHint));

4
spring-web/src/test/java/org/springframework/http/client/support/InterceptingHttpAccessorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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 org.springframework.http.client.ClientHttpResponse; @@ -30,7 +30,6 @@ import org.springframework.http.client.ClientHttpResponse;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link InterceptingHttpAccessor}.
*
@ -40,6 +39,7 @@ public class InterceptingHttpAccessorTests { @@ -40,6 +39,7 @@ public class InterceptingHttpAccessorTests {
@Test
public void getInterceptors() {
@SuppressWarnings("resource")
TestInterceptingHttpAccessor accessor = new TestInterceptingHttpAccessor();
List<ClientHttpRequestInterceptor> interceptors = Arrays.asList(
new SecondClientHttpRequestInterceptor(),

1
spring-web/src/test/java/org/springframework/http/server/reactive/AsyncIntegrationTests.java

@ -52,6 +52,7 @@ class AsyncIntegrationTests extends AbstractHttpHandlerIntegrationTests { @@ -52,6 +52,7 @@ class AsyncIntegrationTests extends AbstractHttpHandlerIntegrationTests {
startServer(httpServer);
URI url = new URI("http://localhost:" + port);
@SuppressWarnings("resource")
ResponseEntity<String> response = new RestTemplate().exchange(RequestEntity.get(url).build(), String.class);
assertThat(response.getBody()).isEqualTo("hello");

1
spring-web/src/test/java/org/springframework/http/server/reactive/CookieIntegrationTests.java

@ -53,6 +53,7 @@ public class CookieIntegrationTests extends AbstractHttpHandlerIntegrationTests @@ -53,6 +53,7 @@ public class CookieIntegrationTests extends AbstractHttpHandlerIntegrationTests
URI url = new URI("http://localhost:" + port);
String header = "SID=31d4d96e407aad42; lang=en-US";
@SuppressWarnings("resource")
ResponseEntity<Void> response = new RestTemplate().exchange(
RequestEntity.get(url).header("Cookie", header).build(), Void.class);

3
spring-web/src/test/java/org/springframework/http/server/reactive/EchoHandlerIntegrationTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@ -49,6 +49,7 @@ public class EchoHandlerIntegrationTests extends AbstractHttpHandlerIntegrationT @@ -49,6 +49,7 @@ public class EchoHandlerIntegrationTests extends AbstractHttpHandlerIntegrationT
public void echo(HttpServer httpServer) throws Exception {
startServer(httpServer);
@SuppressWarnings("resource")
RestTemplate restTemplate = new RestTemplate();
byte[] body = randomBytes();

3
spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java

@ -49,6 +49,7 @@ class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests { @@ -49,6 +49,7 @@ class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
void responseBodyError(HttpServer httpServer) throws Exception {
startServer(httpServer);
@SuppressWarnings("resource")
RestTemplate restTemplate = new RestTemplate();
restTemplate.setErrorHandler(NO_OP_ERROR_HANDLER);
@ -62,6 +63,7 @@ class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests { @@ -62,6 +63,7 @@ class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
void handlingError(HttpServer httpServer) throws Exception {
startServer(httpServer);
@SuppressWarnings("resource")
RestTemplate restTemplate = new RestTemplate();
restTemplate.setErrorHandler(NO_OP_ERROR_HANDLER);
@ -75,6 +77,7 @@ class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests { @@ -75,6 +77,7 @@ class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
void emptyPathSegments(HttpServer httpServer) throws Exception {
startServer(httpServer);
@SuppressWarnings("resource")
RestTemplate restTemplate = new RestTemplate();
restTemplate.setErrorHandler(NO_OP_ERROR_HANDLER);

3
spring-web/src/test/java/org/springframework/http/server/reactive/MultipartIntegrationTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@ -57,6 +57,7 @@ class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTests { @@ -57,6 +57,7 @@ class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTests {
void getFormParts(HttpServer httpServer) throws Exception {
startServer(httpServer);
@SuppressWarnings("resource")
RestTemplate restTemplate = new RestTemplate();
RequestEntity<MultiValueMap<String, Object>> request = RequestEntity
.post(new URI("http://localhost:" + port + "/form-parts"))

3
spring-web/src/test/java/org/springframework/http/server/reactive/RandomHandlerIntegrationTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 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.
@ -59,6 +59,7 @@ class RandomHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests @@ -59,6 +59,7 @@ class RandomHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests
// TODO: fix Reactor support
@SuppressWarnings("resource")
RestTemplate restTemplate = new RestTemplate();
byte[] body = randomBytes();

1
spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestIntegrationTests.java

@ -46,6 +46,7 @@ class ServerHttpRequestIntegrationTests extends AbstractHttpHandlerIntegrationTe @@ -46,6 +46,7 @@ class ServerHttpRequestIntegrationTests extends AbstractHttpHandlerIntegrationTe
URI url = new URI("http://localhost:" + port + "/foo?param=bar");
RequestEntity<Void> request = RequestEntity.post(url).build();
@SuppressWarnings("resource")
ResponseEntity<Void> response = new RestTemplate().exchange(request, Void.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
}

3
spring-web/src/test/java/org/springframework/http/server/reactive/WriteOnlyHandlerIntegrationTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@ -54,6 +54,7 @@ class WriteOnlyHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTes @@ -54,6 +54,7 @@ class WriteOnlyHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTes
void writeOnly(HttpServer httpServer) throws Exception {
startServer(httpServer);
@SuppressWarnings("resource")
RestTemplate restTemplate = new RestTemplate();
this.body = randomBytes();

1
spring-web/src/test/java/org/springframework/http/server/reactive/ZeroCopyIntegrationTests.java

@ -61,6 +61,7 @@ class ZeroCopyIntegrationTests extends AbstractHttpHandlerIntegrationTests { @@ -61,6 +61,7 @@ class ZeroCopyIntegrationTests extends AbstractHttpHandlerIntegrationTests {
URI url = new URI("http://localhost:" + port);
RequestEntity<?> request = RequestEntity.get(url).build();
@SuppressWarnings("resource")
ResponseEntity<byte[]> response = new RestTemplate().exchange(request, byte[].class);
assertThat(response.hasBody()).isTrue();

1
spring-web/src/test/java/org/springframework/web/client/RestTemplateTests.java

@ -106,6 +106,7 @@ class RestTemplateTests { @@ -106,6 +106,7 @@ class RestTemplateTests {
@Test // gh-29008
void defaultMessageConvertersWithKotlinSerialization() {
@SuppressWarnings("resource")
RestTemplate restTemplate = new RestTemplate();
List<HttpMessageConverter<?>> httpMessageConverters = restTemplate.getMessageConverters();
assertThat(httpMessageConverters).extracting("class").containsOnlyOnce(

4
spring-webflux/src/test/java/org/springframework/web/reactive/result/SimpleUrlHandlerMappingIntegrationTests.java

@ -72,6 +72,7 @@ class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandlerIntegra @@ -72,6 +72,7 @@ class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandlerIntegra
URI url = new URI("http://localhost:" + this.port + "/foo");
RequestEntity<Void> request = RequestEntity.get(url).build();
@SuppressWarnings("resource")
ResponseEntity<byte[]> response = new RestTemplate().exchange(request, byte[].class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
@ -84,6 +85,7 @@ class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandlerIntegra @@ -84,6 +85,7 @@ class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandlerIntegra
URI url = new URI("http://localhost:" + this.port + "/bar");
RequestEntity<Void> request = RequestEntity.get(url).build();
@SuppressWarnings("resource")
ResponseEntity<byte[]> response = new RestTemplate().exchange(request, byte[].class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
@ -96,6 +98,7 @@ class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandlerIntegra @@ -96,6 +98,7 @@ class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandlerIntegra
URI url = new URI("http://localhost:" + this.port + "/header");
RequestEntity<Void> request = RequestEntity.get(url).build();
@SuppressWarnings("resource")
ResponseEntity<byte[]> response = new RestTemplate().exchange(request, byte[].class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
@ -103,6 +106,7 @@ class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandlerIntegra @@ -103,6 +106,7 @@ class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandlerIntegra
}
@ParameterizedHttpServerTest
@SuppressWarnings("resource")
void handlerNotFound(HttpServer httpServer) throws Exception {
startServer(httpServer);

4
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ContextPathIntegrationTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@ -55,6 +55,7 @@ class ContextPathIntegrationTests { @@ -55,6 +55,7 @@ class ContextPathIntegrationTests {
server.start();
try {
@SuppressWarnings("resource")
RestTemplate restTemplate = new RestTemplate();
String actual;
@ -87,6 +88,7 @@ class ContextPathIntegrationTests { @@ -87,6 +88,7 @@ class ContextPathIntegrationTests {
try {
String url = "http://localhost:" + server.getPort() + "/app/api/test";
@SuppressWarnings("resource")
String actual = new RestTemplate().getForObject(url, String.class);
assertThat(actual).isEqualTo("Tested in /app/api");
}

3
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingViewResolutionIntegrationTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@ -94,6 +94,7 @@ class RequestMappingViewResolutionIntegrationTests extends AbstractRequestMappin @@ -94,6 +94,7 @@ class RequestMappingViewResolutionIntegrationTests extends AbstractRequestMappin
URI uri = new URI("http://localhost:" + this.port + "/redirect");
RequestEntity<Void> request = RequestEntity.get(uri).accept(MediaType.ALL).build();
@SuppressWarnings("resource")
ResponseEntity<Void> response = new RestTemplate(factory).exchange(request, Void.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.SEE_OTHER);

Loading…
Cancel
Save