Browse Source

Clean up warnings in spring-web

pull/1090/merge
Sam Brannen 10 years ago
parent
commit
3f317b7d3f
  1. 1
      spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java
  2. 1
      spring-web/src/main/java/org/springframework/http/client/reactive/ReactorClientHttpRequest.java
  3. 6
      spring-web/src/main/java/org/springframework/http/client/reactive/ReactorClientHttpResponse.java
  4. 5
      spring-web/src/main/java/org/springframework/http/codec/json/JsonObjectDecoder.java
  5. 2
      spring-web/src/main/java/org/springframework/http/converter/ResourceRegionHttpMessageConverter.java
  6. 1
      spring-web/src/main/java/org/springframework/http/converter/reactive/CodecHttpMessageConverter.java
  7. 3
      spring-web/src/main/java/org/springframework/http/converter/reactive/HttpMessageConverter.java
  8. 7
      spring-web/src/main/java/org/springframework/http/converter/reactive/ResourceHttpMessageConverter.java
  9. 2
      spring-web/src/main/java/org/springframework/http/converter/support/AllEncompassingFormHttpMessageConverter.java
  10. 1
      spring-web/src/main/java/org/springframework/http/server/ServletServerHttpResponse.java
  11. 1
      spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpResponse.java
  12. 1
      spring-web/src/main/java/org/springframework/remoting/httpinvoker/HttpComponentsHttpInvokerRequestExecutor.java
  13. 1
      spring-web/src/main/java/org/springframework/web/client/RestTemplate.java
  14. 2
      spring-web/src/main/java/org/springframework/web/client/reactive/WebClient.java
  15. 5
      spring-web/src/test/java/org/springframework/http/client/OkHttpAsyncClientHttpRequestFactoryTests.java
  16. 3
      spring-web/src/test/java/org/springframework/http/client/OkHttpClientHttpRequestFactoryTests.java
  17. 2
      spring-web/src/test/java/org/springframework/http/codec/json/JacksonJsonDecoderTests.java
  18. 2
      spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2EncoderTests.java
  19. 1
      spring-web/src/test/java/org/springframework/http/converter/json/SpringHandlerInstantiatorTests.java
  20. 12
      spring-web/src/test/java/org/springframework/http/server/reactive/AsyncIntegrationTests.java
  21. 15
      spring-web/src/test/java/org/springframework/http/server/reactive/ChannelSendOperatorTests.java
  22. 3
      spring-web/src/test/java/org/springframework/http/server/reactive/FlushingIntegrationTests.java
  23. 6
      spring-web/src/test/java/org/springframework/http/server/reactive/RandomHandlerIntegrationTests.java
  24. 2
      spring-web/src/test/java/org/springframework/http/server/reactive/ZeroCopyIntegrationTests.java
  25. 1
      spring-web/src/test/java/org/springframework/remoting/caucho/CauchoRemotingTests.java
  26. 6
      spring-web/src/test/java/org/springframework/web/server/handler/ExceptionHandlingHttpHandlerTests.java
  27. 3
      spring-web/src/test/java/org/springframework/web/server/session/WebSessionIntegrationTests.java

1
spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java

@ -39,7 +39,6 @@ import org.apache.http.protocol.HttpContext; @@ -39,7 +39,6 @@ import org.apache.http.protocol.HttpContext;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.http.HttpMethod;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
/**
* {@link org.springframework.http.client.ClientHttpRequestFactory} implementation that

1
spring-web/src/main/java/org/springframework/http/client/reactive/ReactorClientHttpRequest.java

@ -24,7 +24,6 @@ import io.netty.handler.codec.http.cookie.DefaultCookie; @@ -24,7 +24,6 @@ import io.netty.handler.codec.http.cookie.DefaultCookie;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.io.netty.http.HttpClient;
import reactor.io.netty.http.HttpClientRequest;
import org.springframework.core.io.buffer.DataBuffer;

6
spring-web/src/main/java/org/springframework/http/client/reactive/ReactorClientHttpResponse.java

@ -17,14 +17,11 @@ @@ -17,14 +17,11 @@
package org.springframework.http.client.reactive;
import java.util.Collection;
import java.util.function.Function;
import io.netty.buffer.ByteBuf;
import reactor.core.publisher.Flux;
import reactor.io.netty.http.HttpClientResponse;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DataBufferFactory;
import org.springframework.core.io.buffer.NettyDataBufferFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
@ -96,4 +93,5 @@ public class ReactorClientHttpResponse implements ClientHttpResponse { @@ -96,4 +93,5 @@ public class ReactorClientHttpResponse implements ClientHttpResponse {
"status=" + getStatusCode() +
'}';
}
}
}

5
spring-web/src/main/java/org/springframework/http/codec/json/JsonObjectDecoder.java

@ -38,11 +38,11 @@ import org.springframework.util.MimeType; @@ -38,11 +38,11 @@ import org.springframework.util.MimeType;
* Decode an arbitrary split byte stream representing JSON objects to a byte
* stream where each chunk is a well-formed JSON object.
*
* This class does not do any real parsing or validation. A sequence of byte
* <p>This class does not do any real parsing or validation. A sequence of bytes
* is considered a JSON object/array if it contains a matching number of opening
* and closing braces/brackets.
*
* Based on <a href="https://github.com/netty/netty/blob/master/codec/src/main/java/io/netty/handler/codec/json/JsonObjectDecoder.java">Netty JsonObjectDecoder</a>
* <p>Based on <a href="https://github.com/netty/netty/blob/master/codec/src/main/java/io/netty/handler/codec/json/JsonObjectDecoder.java">Netty JsonObjectDecoder</a>
*
* @author Sebastien Deleuze
* @since 5.0
@ -220,7 +220,6 @@ class JsonObjectDecoder extends AbstractDecoder<DataBuffer> { @@ -220,7 +220,6 @@ class JsonObjectDecoder extends AbstractDecoder<DataBuffer> {
* Override this method if you want to filter the json objects/arrays that
* get passed through the pipeline.
*/
@SuppressWarnings("UnusedParameters")
protected ByteBuf extractObject(ByteBuf buffer, int index, int length) {
return buffer.slice(index, length).retain();
}

2
spring-web/src/main/java/org/springframework/http/converter/ResourceRegionHttpMessageConverter.java

@ -79,7 +79,7 @@ public class ResourceRegionHttpMessageConverter extends AbstractGenericHttpMessa @@ -79,7 +79,7 @@ public class ResourceRegionHttpMessageConverter extends AbstractGenericHttpMessa
@Override
public boolean canWrite(Type type, Class<?> clazz, MediaType mediaType) {
if (!(type instanceof ParameterizedType)) {
return ResourceRegion.class.isAssignableFrom((Class) type);
return ResourceRegion.class.isAssignableFrom((Class<?>) type);
}
ParameterizedType parameterizedType = (ParameterizedType) type;
if (!(parameterizedType.getRawType() instanceof Class)) {

1
spring-web/src/main/java/org/springframework/http/converter/reactive/CodecHttpMessageConverter.java

@ -181,7 +181,6 @@ public class CodecHttpMessageConverter<T> implements HttpMessageConverter<T> { @@ -181,7 +181,6 @@ public class CodecHttpMessageConverter<T> implements HttpMessageConverter<T> {
* @param elementType the type of element for encoding
* @return the content type, or {@code null}
*/
@SuppressWarnings("UnusedParameters")
protected MediaType getDefaultContentType(ResolvableType elementType) {
return (!this.writableMediaTypes.isEmpty() ? this.writableMediaTypes.get(0) : null);
}

3
spring-web/src/main/java/org/springframework/http/converter/reactive/HttpMessageConverter.java

@ -100,4 +100,5 @@ public interface HttpMessageConverter<T> { @@ -100,4 +100,5 @@ public interface HttpMessageConverter<T> {
Mono<Void> write(Publisher<? extends T> inputStream,
ResolvableType type, MediaType contentType,
ReactiveHttpOutputMessage outputMessage);
}
}

7
spring-web/src/main/java/org/springframework/http/converter/reactive/ResourceHttpMessageConverter.java

@ -39,7 +39,7 @@ import org.springframework.util.ResourceUtils; @@ -39,7 +39,7 @@ import org.springframework.util.ResourceUtils;
/**
* Implementation of {@link HttpMessageConverter} that can read and write
* {@link Resource Resources} and supports byte range requests.
**
*
* @author Arjen Poutsma
* @since 5.0
*/
@ -53,6 +53,7 @@ public class ResourceHttpMessageConverter extends CodecHttpMessageConverter<Reso @@ -53,6 +53,7 @@ public class ResourceHttpMessageConverter extends CodecHttpMessageConverter<Reso
super(new ResourceEncoder(bufferSize), new ResourceDecoder());
}
@Override
public Mono<Void> write(Publisher<? extends Resource> inputStream,
ResolvableType type, MediaType contentType,
@ -92,8 +93,7 @@ public class ResourceHttpMessageConverter extends CodecHttpMessageConverter<Reso @@ -92,8 +93,7 @@ public class ResourceHttpMessageConverter extends CodecHttpMessageConverter<Reso
ZeroCopyHttpOutputMessage zeroCopyResponse =
(ZeroCopyHttpOutputMessage) outputMessage;
return zeroCopyResponse
.writeWith(file.get(), (long) 0, file.get().length());
return zeroCopyResponse.writeWith(file.get(), 0, file.get().length());
}
}
@ -127,5 +127,4 @@ public class ResourceHttpMessageConverter extends CodecHttpMessageConverter<Reso @@ -127,5 +127,4 @@ public class ResourceHttpMessageConverter extends CodecHttpMessageConverter<Reso
return Optional.empty();
}
}

2
spring-web/src/main/java/org/springframework/http/converter/support/AllEncompassingFormHttpMessageConverter.java

@ -16,8 +16,6 @@ @@ -16,8 +16,6 @@
package org.springframework.http.converter.support;
import javax.xml.transform.Source;
import org.springframework.http.converter.FormHttpMessageConverter;
import org.springframework.http.converter.json.GsonHttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;

1
spring-web/src/main/java/org/springframework/http/server/ServletServerHttpResponse.java

@ -27,7 +27,6 @@ import javax.servlet.http.HttpServletResponse; @@ -27,7 +27,6 @@ import javax.servlet.http.HttpServletResponse;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.CollectionUtils;
/**

1
spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpResponse.java

@ -114,6 +114,7 @@ public class UndertowServerHttpResponse extends AbstractServerHttpResponse @@ -114,6 +114,7 @@ public class UndertowServerHttpResponse extends AbstractServerHttpResponse
try {
StreamSinkChannel responseChannel =
getUndertowExchange().getResponseChannel();
@SuppressWarnings("resource")
FileChannel in = new FileInputStream(file).getChannel();
long result = responseChannel.transferFrom(in, position, count);
if (result < count) {

1
spring-web/src/main/java/org/springframework/remoting/httpinvoker/HttpComponentsHttpInvokerRequestExecutor.java

@ -43,7 +43,6 @@ import org.springframework.context.i18n.LocaleContext; @@ -43,7 +43,6 @@ import org.springframework.context.i18n.LocaleContext;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.remoting.support.RemoteInvocationResult;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
/**

1
spring-web/src/main/java/org/springframework/web/client/RestTemplate.java

@ -23,7 +23,6 @@ import java.util.ArrayList; @@ -23,7 +23,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.xml.transform.Source;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;

2
spring-web/src/main/java/org/springframework/web/client/reactive/WebClient.java

@ -205,7 +205,7 @@ public final class WebClient { @@ -205,7 +205,7 @@ public final class WebClient {
}
}
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
protected Mono<Void> writeRequestBody(Publisher<?> content,
ResolvableType requestType, ClientHttpRequest request,
List<HttpMessageConverter<?>> messageConverters) {

5
spring-web/src/test/java/org/springframework/http/client/OkHttpAsyncClientHttpRequestFactoryTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@ -25,7 +25,8 @@ import org.springframework.http.HttpMethod; @@ -25,7 +25,8 @@ import org.springframework.http.HttpMethod;
*/
public class OkHttpAsyncClientHttpRequestFactoryTests extends AbstractAsyncHttpRequestFactoryTestCase {
@Override
@Override
@SuppressWarnings("deprecation")
protected AsyncClientHttpRequestFactory createRequestFactory() {
return new OkHttpClientHttpRequestFactory();
}

3
spring-web/src/test/java/org/springframework/http/client/OkHttpClientHttpRequestFactoryTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@ -26,6 +26,7 @@ import org.springframework.http.HttpMethod; @@ -26,6 +26,7 @@ import org.springframework.http.HttpMethod;
public class OkHttpClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTestCase {
@Override
@SuppressWarnings("deprecation")
protected ClientHttpRequestFactory createRequestFactory() {
return new OkHttpClientHttpRequestFactory();
}

2
spring-web/src/test/java/org/springframework/http/codec/json/JacksonJsonDecoderTests.java

@ -84,9 +84,7 @@ public class JacksonJsonDecoderTests extends AbstractDataBufferAllocatingTestCas @@ -84,9 +84,7 @@ public class JacksonJsonDecoderTests extends AbstractDataBufferAllocatingTestCas
assertValues(new Pojo("f1", "b1"), new Pojo("f2", "b2"));
}
@SuppressWarnings("unused")
void handle(List<Pojo> list) {
}
}

2
spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2EncoderTests.java

@ -34,9 +34,9 @@ import org.springframework.http.MediaType; @@ -34,9 +34,9 @@ import org.springframework.http.MediaType;
import org.springframework.http.codec.Pojo;
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.custommonkey.xmlunit.XMLAssert.fail;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* @author Sebastien Deleuze

1
spring-web/src/test/java/org/springframework/http/converter/json/SpringHandlerInstantiatorTests.java

@ -197,7 +197,6 @@ public class SpringHandlerInstantiatorTests { @@ -197,7 +197,6 @@ public class SpringHandlerInstantiatorTests {
}
// Only needed when compiling against Jackson 2.7; gone in 2.8
@SuppressWarnings("deprecation")
public JavaType typeFromId(String s) {
return TypeFactory.defaultInstance().constructFromCanonical(s);
}

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

@ -35,9 +35,8 @@ import org.springframework.web.client.RestTemplate; @@ -35,9 +35,8 @@ import org.springframework.web.client.RestTemplate;
import static org.junit.Assert.assertThat;
/**
* Temporarily does not extend AbstractHttpHandlerIntegrationTests.
*
* @author Stephane Maldini
* @since 5.0
*/
public class AsyncIntegrationTests extends AbstractHttpHandlerIntegrationTests {
@ -50,12 +49,11 @@ public class AsyncIntegrationTests extends AbstractHttpHandlerIntegrationTests { @@ -50,12 +49,11 @@ public class AsyncIntegrationTests extends AbstractHttpHandlerIntegrationTests {
return new AsyncHandler();
}
@SuppressWarnings("unchecked")
@Test
public void basicTest() throws Exception {
URI url = new URI("http://localhost:" + port);
ResponseEntity<String> response = new RestTemplate().exchange(RequestEntity.get(url)
.build(), String.class);
ResponseEntity<String> response = new RestTemplate().exchange(
RequestEntity.get(url).build(), String.class);
assertThat(response.getBody(), Matchers.equalTo("hello"));
}
@ -65,8 +63,8 @@ public class AsyncIntegrationTests extends AbstractHttpHandlerIntegrationTests { @@ -65,8 +63,8 @@ public class AsyncIntegrationTests extends AbstractHttpHandlerIntegrationTests {
@Override
public Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response) {
return response.writeWith(Flux.just("h", "e", "l", "l", "o")
.delay(Duration.ofMillis(100))
.publishOn(asyncGroup)
.delay(Duration.ofMillis(100))
.publishOn(asyncGroup)
.collect(dataBufferFactory::allocateBuffer, (buffer, str) -> buffer.write(str.getBytes())));
}
}

15
spring-web/src/test/java/org/springframework/http/server/reactive/ChannelSendOperatorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.http.server.reactive;
import java.util.ArrayList;
@ -37,7 +38,6 @@ import static org.junit.Assert.*; @@ -37,7 +38,6 @@ import static org.junit.Assert.*;
* @author Rossen Stoyanchev
* @author Stephane Maldini
*/
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
public class ChannelSendOperatorTests {
private OneByOneAsyncWriter writer;
@ -176,15 +176,4 @@ public class ChannelSendOperatorTests { @@ -176,15 +176,4 @@ public class ChannelSendOperatorTests {
}
}
private final static Subscription NO_OP_SUBSCRIPTION = new Subscription() {
@Override
public void request(long n) {
}
@Override
public void cancel() {
}
};
}

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

@ -19,8 +19,6 @@ package org.springframework.http.server.reactive; @@ -19,8 +19,6 @@ package org.springframework.http.server.reactive;
import org.junit.Before;
import org.junit.Test;
import static org.springframework.web.client.reactive.ClientWebRequestBuilders.get;
import static org.springframework.web.client.reactive.ResponseExtractors.bodyStream;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.test.TestSubscriber;
@ -87,4 +85,5 @@ public class FlushingIntegrationTests extends AbstractHttpHandlerIntegrationTest @@ -87,4 +85,5 @@ public class FlushingIntegrationTests extends AbstractHttpHandlerIntegrationTest
return response.writeWith(responseBody);
}
}
}

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

@ -89,17 +89,11 @@ public class RandomHandlerIntegrationTests extends AbstractHttpHandlerIntegratio @@ -89,17 +89,11 @@ public class RandomHandlerIntegrationTests extends AbstractHttpHandlerIntegratio
assertEquals(REQUEST_SIZE, (long) size);
});
response.getHeaders().setContentLength(RESPONSE_SIZE);
return requestSizeMono.then(response.writeWith(multipleChunks()));
}
private Publisher<DataBuffer> singleChunk() {
return Mono.just(randomBuffer(RESPONSE_SIZE));
}
private Publisher<DataBuffer> multipleChunks() {
int chunkSize = RESPONSE_SIZE / CHUNKS;
return Flux.range(1, CHUNKS).map(integer -> randomBuffer(chunkSize));

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

@ -56,7 +56,7 @@ public class ZeroCopyIntegrationTests extends AbstractHttpHandlerIntegrationTest @@ -56,7 +56,7 @@ public class ZeroCopyIntegrationTests extends AbstractHttpHandlerIntegrationTest
RestTemplate restTemplate = new RestTemplate();
RequestEntity request =
RequestEntity<?> request =
RequestEntity.get(new URI("http://localhost:" + port)).build();
ResponseEntity<byte[]> response = restTemplate.exchange(request, byte[].class);

1
spring-web/src/test/java/org/springframework/remoting/caucho/CauchoRemotingTests.java

@ -38,7 +38,6 @@ import static org.junit.Assert.*; @@ -38,7 +38,6 @@ import static org.junit.Assert.*;
* @author Sam Brannen
* @since 16.05.2003
*/
@SuppressWarnings("deprecation")
public class CauchoRemotingTests {
@Rule

6
spring-web/src/test/java/org/springframework/web/server/handler/ExceptionHandlingHttpHandlerTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@ -13,8 +13,8 @@ @@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.server.handler;
package org.springframework.web.server.handler;
import java.net.URI;
@ -37,8 +37,8 @@ import static org.junit.Assert.assertEquals; @@ -37,8 +37,8 @@ import static org.junit.Assert.assertEquals;
/**
* @author Rossen Stoyanchev
* @since 5.0
*/
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
public class ExceptionHandlingHttpHandlerTests {
private MockServerHttpResponse response;

3
spring-web/src/test/java/org/springframework/web/server/session/WebSessionIntegrationTests.java

@ -13,13 +13,13 @@ @@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.server.session;
import java.net.URI;
import java.net.URISyntaxException;
import java.time.Clock;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
@ -133,7 +133,6 @@ public class WebSessionIntegrationTests extends AbstractHttpHandlerIntegrationTe @@ -133,7 +133,6 @@ public class WebSessionIntegrationTests extends AbstractHttpHandlerIntegrationTe
assertNotNull(headerValues);
assertEquals(1, headerValues.size());
List<String> data = new ArrayList<>();
for (String s : headerValues.get(0).split(";")){
if (s.startsWith("SESSION=")) {
return s.substring("SESSION=".length());

Loading…
Cancel
Save