Clean up warnings in spring-web
This commit is contained in:
parent
f188aab5f2
commit
9b61316c2e
|
|
@ -161,6 +161,7 @@ public class HttpComponentsAsyncClientHttpRequestFactory extends HttpComponentsC
|
|||
private HttpAsyncClient startAsyncClient() {
|
||||
HttpAsyncClient client = getAsyncClient();
|
||||
if (client instanceof CloseableHttpAsyncClient) {
|
||||
@SuppressWarnings("resource")
|
||||
CloseableHttpAsyncClient closeableAsyncClient = (CloseableHttpAsyncClient) client;
|
||||
if (!closeableAsyncClient.isRunning()) {
|
||||
closeableAsyncClient.start();
|
||||
|
|
|
|||
|
|
@ -69,8 +69,8 @@ public class DecoderHttpMessageReader<T> implements HttpMessageReader<T> {
|
|||
private static void initLogger(Decoder<?> decoder) {
|
||||
if (decoder instanceof AbstractDecoder &&
|
||||
decoder.getClass().getName().startsWith("org.springframework.core.codec")) {
|
||||
Log logger = HttpLogging.forLog(((AbstractDecoder) decoder).getLogger());
|
||||
((AbstractDecoder) decoder).setLogger(logger);
|
||||
Log logger = HttpLogging.forLog(((AbstractDecoder<?>) decoder).getLogger());
|
||||
((AbstractDecoder<?>) decoder).setLogger(logger);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,8 +79,8 @@ public class EncoderHttpMessageWriter<T> implements HttpMessageWriter<T> {
|
|||
private static void initLogger(Encoder<?> encoder) {
|
||||
if (encoder instanceof AbstractEncoder &&
|
||||
encoder.getClass().getName().startsWith("org.springframework.core.codec")) {
|
||||
Log logger = HttpLogging.forLog(((AbstractEncoder) encoder).getLogger());
|
||||
((AbstractEncoder) encoder).setLogger(logger);
|
||||
Log logger = HttpLogging.forLog(((AbstractEncoder<?>) encoder).getLogger());
|
||||
((AbstractEncoder<?>) encoder).setLogger(logger);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -108,7 +108,6 @@ public class EncoderHttpMessageWriter<T> implements HttpMessageWriter<T> {
|
|||
return this.encoder.canEncode(elementType, mediaType);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Mono<Void> write(Publisher<? extends T> inputStream, ResolvableType elementType,
|
||||
@Nullable MediaType mediaType, ReactiveHttpOutputMessage message, Map<String, Object> hints) {
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs {
|
|||
* or for multipart requests only ("true"). Generally the two sets are the
|
||||
* same except for the multipart writer itself.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
final List<HttpMessageWriter<?>> getTypedWriters(boolean forMultipart) {
|
||||
if (!this.registerDefaults) {
|
||||
return Collections.emptyList();
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ public class ServerSentEventHttpMessageReaderTests extends AbstractLeakCheckingT
|
|||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void readServerSentEvents() {
|
||||
MockServerHttpRequest request = MockServerHttpRequest.post("/")
|
||||
.body(Mono.just(stringBuffer(
|
||||
|
|
@ -91,6 +92,7 @@ public class ServerSentEventHttpMessageReaderTests extends AbstractLeakCheckingT
|
|||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void readServerSentEventsWithMultipleChunks() {
|
||||
MockServerHttpRequest request = MockServerHttpRequest.post("/")
|
||||
.body(Flux.just(
|
||||
|
|
@ -199,5 +201,4 @@ public class ServerSentEventHttpMessageReaderTests extends AbstractLeakCheckingT
|
|||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -215,6 +215,7 @@ public class Jackson2JsonDecoderTests extends AbstractDecoderTestCase<Jackson2Js
|
|||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class BeanWithNoDefaultConstructor {
|
||||
|
||||
private final String property1;
|
||||
|
|
|
|||
|
|
@ -271,7 +271,8 @@ public class MultipartHttpMessageWriterTests extends AbstractLeakCheckingTestCas
|
|||
}
|
||||
|
||||
|
||||
private class Foo {
|
||||
@SuppressWarnings("unused")
|
||||
private static class Foo {
|
||||
|
||||
private String bar;
|
||||
|
||||
|
|
|
|||
|
|
@ -651,6 +651,7 @@ public class Jackson2ObjectMapperBuilderTests {
|
|||
|
||||
public static class JacksonVisibilityBean {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private String property1;
|
||||
|
||||
public String property2;
|
||||
|
|
|
|||
|
|
@ -614,6 +614,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
|||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class BeanWithNoDefaultConstructor {
|
||||
|
||||
private final String property1;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import java.io.IOException;
|
|||
import com.google.protobuf.ExtensionRegistry;
|
||||
import com.google.protobuf.Message;
|
||||
import com.google.protobuf.util.JsonFormat;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
|
|
@ -47,23 +46,12 @@ import static org.mockito.Mockito.verify;
|
|||
@SuppressWarnings("deprecation")
|
||||
public class ProtobufJsonFormatHttpMessageConverterTests {
|
||||
|
||||
private ProtobufHttpMessageConverter converter;
|
||||
private final ExtensionRegistryInitializer registryInitializer = mock(ExtensionRegistryInitializer.class);
|
||||
|
||||
private ExtensionRegistry extensionRegistry;
|
||||
private final ProtobufHttpMessageConverter converter = new ProtobufJsonFormatHttpMessageConverter(
|
||||
JsonFormat.parser(), JsonFormat.printer(), this.registryInitializer);
|
||||
|
||||
private ExtensionRegistryInitializer registryInitializer;
|
||||
|
||||
private Msg testMsg;
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.registryInitializer = mock(ExtensionRegistryInitializer.class);
|
||||
this.extensionRegistry = mock(ExtensionRegistry.class);
|
||||
this.converter = new ProtobufJsonFormatHttpMessageConverter(
|
||||
JsonFormat.parser(), JsonFormat.printer(), this.registryInitializer);
|
||||
this.testMsg = Msg.newBuilder().setFoo("Foo").setBlah(SecondMsg.newBuilder().setBlah(123).build()).build();
|
||||
}
|
||||
private final Msg testMsg = Msg.newBuilder().setFoo("Foo").setBlah(SecondMsg.newBuilder().setBlah(123).build()).build();
|
||||
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -253,6 +253,7 @@ public class WebExchangeDataBinderTests {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class MultipartBean {
|
||||
|
||||
private String name;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class ExtractingResponseErrorHandlerTests {
|
|||
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
public void setup() {
|
||||
HttpMessageConverter<Object> converter = new MappingJackson2HttpMessageConverter();
|
||||
this.errorHandler = new ExtractingResponseErrorHandler(
|
||||
Collections.singletonList(converter));
|
||||
|
|
@ -184,9 +184,6 @@ public class ExtractingResponseErrorHandlerTests {
|
|||
return this.foo;
|
||||
}
|
||||
|
||||
public void setFoo(String foo) {
|
||||
this.foo = foo;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -222,11 +222,11 @@ public class RestTemplateTests {
|
|||
|
||||
@Test
|
||||
public void requestAvoidsDuplicateAcceptHeaderValues() throws Exception {
|
||||
HttpMessageConverter firstConverter = mock(HttpMessageConverter.class);
|
||||
HttpMessageConverter<?> firstConverter = mock(HttpMessageConverter.class);
|
||||
given(firstConverter.canRead(any(), any())).willReturn(true);
|
||||
given(firstConverter.getSupportedMediaTypes())
|
||||
.willReturn(Collections.singletonList(MediaType.TEXT_PLAIN));
|
||||
HttpMessageConverter secondConverter = mock(HttpMessageConverter.class);
|
||||
HttpMessageConverter<?> secondConverter = mock(HttpMessageConverter.class);
|
||||
given(secondConverter.canRead(any(), any())).willReturn(true);
|
||||
given(secondConverter.getSupportedMediaTypes())
|
||||
.willReturn(Collections.singletonList(MediaType.TEXT_PLAIN));
|
||||
|
|
@ -704,7 +704,7 @@ public class RestTemplateTests {
|
|||
mockHttpMessageConverter(MediaType.TEXT_PLAIN, String.class);
|
||||
}
|
||||
|
||||
private void mockHttpMessageConverter(MediaType mediaType, Class type) {
|
||||
private void mockHttpMessageConverter(MediaType mediaType, Class<?> type) {
|
||||
given(converter.canRead(type, null)).willReturn(true);
|
||||
given(converter.canRead(type, mediaType)).willReturn(true);
|
||||
given(converter.getSupportedMediaTypes())
|
||||
|
|
|
|||
|
|
@ -154,8 +154,8 @@ public class WebAsyncManagerTimeoutTests {
|
|||
verify(interceptor).beforeConcurrentHandling(this.asyncWebRequest, callable);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void startCallableProcessingTimeoutAndCheckThreadInterrupted() throws Exception {
|
||||
|
||||
StubCallable callable = new StubCallable();
|
||||
|
|
|
|||
|
|
@ -612,7 +612,7 @@ public class RequestParamMethodArgumentResolverTests {
|
|||
@RequestParam(name = "name", required = false) String paramNotRequired,
|
||||
@RequestParam("name") Optional<Integer> paramOptional,
|
||||
@RequestParam("name") Optional<Integer[]> paramOptionalArray,
|
||||
@RequestParam("name") Optional<List> paramOptionalList,
|
||||
@RequestParam("name") Optional<List<?>> paramOptionalList,
|
||||
@RequestParam("mfile") Optional<MultipartFile> multipartFileOptional) {
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue