Suppress warnings

This commit is contained in:
Sam Brannen
2022-09-14 14:59:50 +02:00
parent e9997d4004
commit 911d1f2dea
16 changed files with 32 additions and 9 deletions

View File

@@ -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 {
}
}
}

View File

@@ -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 {
* @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));

View File

@@ -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;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link InterceptingHttpAccessor}.
*
@@ -40,6 +39,7 @@ public class InterceptingHttpAccessorTests {
@Test
public void getInterceptors() {
@SuppressWarnings("resource")
TestInterceptingHttpAccessor accessor = new TestInterceptingHttpAccessor();
List<ClientHttpRequestInterceptor> interceptors = Arrays.asList(
new SecondClientHttpRequestInterceptor(),

View File

@@ -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");

View File

@@ -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);

View File

@@ -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
public void echo(HttpServer httpServer) throws Exception {
startServer(httpServer);
@SuppressWarnings("resource")
RestTemplate restTemplate = new RestTemplate();
byte[] body = randomBytes();

View File

@@ -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 {
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 {
void emptyPathSegments(HttpServer httpServer) throws Exception {
startServer(httpServer);
@SuppressWarnings("resource")
RestTemplate restTemplate = new RestTemplate();
restTemplate.setErrorHandler(NO_OP_ERROR_HANDLER);

View File

@@ -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 {
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"))

View File

@@ -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
// TODO: fix Reactor support
@SuppressWarnings("resource")
RestTemplate restTemplate = new RestTemplate();
byte[] body = randomBytes();

View File

@@ -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);
}

View File

@@ -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
void writeOnly(HttpServer httpServer) throws Exception {
startServer(httpServer);
@SuppressWarnings("resource")
RestTemplate restTemplate = new RestTemplate();
this.body = randomBytes();

View File

@@ -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();

View File

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

View File

@@ -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
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
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
}
@ParameterizedHttpServerTest
@SuppressWarnings("resource")
void handlerNotFound(HttpServer httpServer) throws Exception {
startServer(httpServer);

View File

@@ -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 {
server.start();
try {
@SuppressWarnings("resource")
RestTemplate restTemplate = new RestTemplate();
String actual;
@@ -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");
}

View File

@@ -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
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);