Clean up warnings and delete dead code

This commit is contained in:
Sam Brannen
2018-08-12 15:54:38 +02:00
parent c4a7567a5e
commit cfb1ed1009
25 changed files with 25 additions and 61 deletions

View File

@@ -55,6 +55,7 @@ public class AnnotationDrivenBeanDefinitionParserTests {
} }
@Test @Test
@SuppressWarnings("rawtypes")
public void asyncPostProcessorExecutorReference() { public void asyncPostProcessorExecutorReference() {
Object executor = context.getBean("testExecutor"); Object executor = context.getBean("testExecutor");
Object aspect = context.getBean(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME); Object aspect = context.getBean(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME);
@@ -62,6 +63,7 @@ public class AnnotationDrivenBeanDefinitionParserTests {
} }
@Test @Test
@SuppressWarnings("rawtypes")
public void asyncPostProcessorExceptionHandlerReference() { public void asyncPostProcessorExceptionHandlerReference() {
Object exceptionHandler = context.getBean("testExceptionHandler"); Object exceptionHandler = context.getBean("testExceptionHandler");
Object aspect = context.getBean(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME); Object aspect = context.getBean(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME);

View File

@@ -284,7 +284,6 @@ public class ValidatorFactoryTests {
errors.initConversion(new DefaultConversionService()); errors.initConversion(new DefaultConversionService());
validator.validate(listContainer, errors); validator.validate(listContainer, errors);
FieldError fieldError = errors.getFieldError("list[1]");
assertEquals("X", errors.getFieldValue("list[1]")); assertEquals("X", errors.getFieldValue("list[1]"));
} }

View File

@@ -42,7 +42,6 @@ import org.springframework.lang.Nullable;
import org.springframework.messaging.Message; import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel; import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHeaders; import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.SubscribableChannel; import org.springframework.messaging.SubscribableChannel;
import org.springframework.messaging.converter.MessageConverter; import org.springframework.messaging.converter.MessageConverter;
import org.springframework.messaging.handler.HandlerMethod; import org.springframework.messaging.handler.HandlerMethod;
@@ -267,9 +266,9 @@ public class SimpAnnotationMethodMessageHandlerTests {
} }
@Test @Test
@SuppressWarnings("unchecked") @SuppressWarnings({ "unchecked", "rawtypes" })
public void listenableFutureSuccess() { public void listenableFutureSuccess() {
Message emptyMessage = (Message) MessageBuilder.withPayload(new byte[0]).build(); Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build();
given(this.channel.send(any(Message.class))).willReturn(true); given(this.channel.send(any(Message.class))).willReturn(true);
given(this.converter.toMessage(any(), any(MessageHeaders.class))).willReturn(emptyMessage); given(this.converter.toMessage(any(), any(MessageHeaders.class))).willReturn(emptyMessage);
@@ -287,9 +286,9 @@ public class SimpAnnotationMethodMessageHandlerTests {
} }
@Test @Test
@SuppressWarnings("unchecked") @SuppressWarnings({ "unchecked", "rawtypes" })
public void listenableFutureFailure() { public void listenableFutureFailure() {
Message emptyMessage = (Message) MessageBuilder.withPayload(new byte[0]).build(); Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build();
given(this.channel.send(any(Message.class))).willReturn(true); given(this.channel.send(any(Message.class))).willReturn(true);
given(this.converter.toMessage(any(), any(MessageHeaders.class))).willReturn(emptyMessage); given(this.converter.toMessage(any(), any(MessageHeaders.class))).willReturn(emptyMessage);
@@ -305,9 +304,9 @@ public class SimpAnnotationMethodMessageHandlerTests {
} }
@Test @Test
@SuppressWarnings("unchecked") @SuppressWarnings({ "unchecked", "rawtypes" })
public void completableFutureSuccess() { public void completableFutureSuccess() {
Message emptyMessage = (Message) MessageBuilder.withPayload(new byte[0]).build(); Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build();
given(this.channel.send(any(Message.class))).willReturn(true); given(this.channel.send(any(Message.class))).willReturn(true);
given(this.converter.toMessage(any(), any(MessageHeaders.class))).willReturn(emptyMessage); given(this.converter.toMessage(any(), any(MessageHeaders.class))).willReturn(emptyMessage);
@@ -325,9 +324,9 @@ public class SimpAnnotationMethodMessageHandlerTests {
} }
@Test @Test
@SuppressWarnings("unchecked") @SuppressWarnings({ "unchecked", "rawtypes" })
public void completableFutureFailure() { public void completableFutureFailure() {
Message emptyMessage = (Message) MessageBuilder.withPayload(new byte[0]).build(); Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build();
given(this.channel.send(any(Message.class))).willReturn(true); given(this.channel.send(any(Message.class))).willReturn(true);
given(this.converter.toMessage(any(), any(MessageHeaders.class))).willReturn(emptyMessage); given(this.converter.toMessage(any(), any(MessageHeaders.class))).willReturn(emptyMessage);
@@ -343,6 +342,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
} }
@Test @Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void monoSuccess() { public void monoSuccess() {
Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build(); Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build();
given(this.channel.send(any(Message.class))).willReturn(true); given(this.channel.send(any(Message.class))).willReturn(true);
@@ -362,6 +362,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
} }
@Test @Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void monoFailure() { public void monoFailure() {
Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build(); Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build();
given(this.channel.send(any(Message.class))).willReturn(true); given(this.channel.send(any(Message.class))).willReturn(true);
@@ -379,6 +380,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
} }
@Test @Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void fluxNotHandled() { public void fluxNotHandled() {
Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build(); Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build();
given(this.channel.send(any(Message.class))).willReturn(true); given(this.channel.send(any(Message.class))).willReturn(true);

View File

@@ -81,7 +81,7 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests
public void testEntityManagerProxyIsProxy() { public void testEntityManagerProxyIsProxy() {
assertTrue(Proxy.isProxyClass(sharedEntityManager.getClass())); assertTrue(Proxy.isProxyClass(sharedEntityManager.getClass()));
Query q = sharedEntityManager.createQuery("select p from Person as p"); Query q = sharedEntityManager.createQuery("select p from Person as p");
List<Person> people = q.getResultList(); q.getResultList();
assertTrue("Should be open to start with", sharedEntityManager.isOpen()); assertTrue("Should be open to start with", sharedEntityManager.isOpen());
sharedEntityManager.close(); sharedEntityManager.close();

View File

@@ -33,7 +33,6 @@ import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionException; import org.springframework.transaction.TransactionException;
import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition; import org.springframework.transaction.support.DefaultTransactionDefinition;

View File

@@ -71,7 +71,7 @@ public class HibernateNativeEntityManagerFactoryIntegrationTests extends Abstrac
} }
@Test @Test
@SuppressWarnings("unchecked") @SuppressWarnings({ "unchecked", "rawtypes" })
public void testCurrentSession() { public void testCurrentSession() {
String firstName = "Tony"; String firstName = "Tony";
insertPerson(firstName); insertPerson(firstName);

View File

@@ -37,7 +37,6 @@ import org.w3c.dom.Element;
import org.w3c.dom.Text; import org.w3c.dom.Text;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import org.xml.sax.XMLReader; import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import org.springframework.util.xml.StaxUtils; import org.springframework.util.xml.StaxUtils;
@@ -98,8 +97,9 @@ public abstract class AbstractUnmarshallerTests<U extends Unmarshaller> {
} }
@Test @Test
@SuppressWarnings("deprecation")
public void unmarshalSAXSource() throws Exception { public void unmarshalSAXSource() throws Exception {
XMLReader reader = XMLReaderFactory.createXMLReader(); XMLReader reader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
SAXSource source = new SAXSource(reader, new InputSource(new StringReader(INPUT_STRING))); SAXSource source = new SAXSource(reader, new InputSource(new StringReader(INPUT_STRING)));
Object flights = unmarshaller.unmarshal(source); Object flights = unmarshaller.unmarshal(source);
testFlights(flights); testFlights(flights);

View File

@@ -13,13 +13,10 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.http; package org.springframework.http;
import java.time.Duration; import java.time.Duration;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import org.junit.Test; import org.junit.Test;

View File

@@ -30,7 +30,6 @@ import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.FileUpload; import org.apache.commons.fileupload.FileUpload;
import org.apache.commons.fileupload.RequestContext; import org.apache.commons.fileupload.RequestContext;
import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.hamcrest.CoreMatchers;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
import org.junit.Test; import org.junit.Test;

View File

@@ -21,7 +21,6 @@ import org.junit.Test;
import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.mock.web.test.server.MockServerWebExchange;
import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.util.pattern.PathPatternParser;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;

View File

@@ -24,13 +24,9 @@ import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test; import org.junit.Test;
import org.springframework.web.util.UriComponents.UriTemplateVariables;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.not;

View File

@@ -21,8 +21,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@@ -74,8 +72,6 @@ public class DispatcherHandler implements WebHandler, ApplicationContextAware {
new ResponseStatusException(HttpStatus.NOT_FOUND, "No matching handler"); new ResponseStatusException(HttpStatus.NOT_FOUND, "No matching handler");
private static final Log logger = LogFactory.getLog(DispatcherHandler.class);
@Nullable @Nullable
private List<HandlerMapping> handlerMappings; private List<HandlerMapping> handlerMappings;

View File

@@ -65,7 +65,6 @@ import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import static org.mockito.Mockito.when;
import static org.springframework.http.codec.json.Jackson2CodecSupport.*; import static org.springframework.http.codec.json.Jackson2CodecSupport.*;
/** /**

View File

@@ -30,7 +30,6 @@ import org.mockito.MockitoAnnotations;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import reactor.test.StepVerifier; import reactor.test.StepVerifier;
import org.springframework.core.NamedInheritableThreadLocal;
import org.springframework.core.NamedThreadLocal; import org.springframework.core.NamedThreadLocal;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;

View File

@@ -82,6 +82,7 @@ public class ClientResponseWrapperTests {
} }
@Test @Test
@SuppressWarnings("unchecked")
public void cookies() { public void cookies() {
MultiValueMap<String, ResponseCookie> cookies = mock(MultiValueMap.class); MultiValueMap<String, ResponseCookie> cookies = mock(MultiValueMap.class);
when(mockResponse.cookies()).thenReturn(cookies); when(mockResponse.cookies()).thenReturn(cookies);

View File

@@ -136,6 +136,7 @@ public class ServerRequestWrapperTests {
} }
@Test @Test
@SuppressWarnings("unchecked")
public void cookies() { public void cookies() {
MultiValueMap<String, HttpCookie> cookies = mock(MultiValueMap.class); MultiValueMap<String, HttpCookie> cookies = mock(MultiValueMap.class);
when(mockRequest.cookies()).thenReturn(cookies); when(mockRequest.cookies()).thenReturn(cookies);

View File

@@ -20,7 +20,6 @@ import java.time.ZoneId;
import java.util.Locale; import java.util.Locale;
import java.util.TimeZone; import java.util.TimeZone;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;

View File

@@ -13,4 +13,4 @@ fun ScriptTemplateWithBindings.i18n(code: String) =
var ScriptTemplateWithBindings.foo: String var ScriptTemplateWithBindings.foo: String
get() = bindings["foo"] as String get() = bindings["foo"] as String
set(value) { throw UnsupportedOperationException() } set(@Suppress("UNUSED_PARAMETER") value) { throw UnsupportedOperationException() }

View File

@@ -23,9 +23,6 @@ import java.util.function.Consumer;
import javax.servlet.ServletRequest; import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.MethodParameter; import org.springframework.core.MethodParameter;
import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.core.ReactiveAdapterRegistry;
import org.springframework.core.ResolvableType; import org.springframework.core.ResolvableType;
@@ -60,9 +57,6 @@ import org.springframework.web.method.support.ModelAndViewContainer;
*/ */
public class ResponseBodyEmitterReturnValueHandler implements HandlerMethodReturnValueHandler { public class ResponseBodyEmitterReturnValueHandler implements HandlerMethodReturnValueHandler {
private static final Log logger = LogFactory.getLog(ResponseBodyEmitterReturnValueHandler.class);
private final List<HttpMessageConverter<?>> messageConverters; private final List<HttpMessageConverter<?>> messageConverters;
private final ReactiveTypeHandler reactiveHandler; private final ReactiveTypeHandler reactiveHandler;

View File

@@ -85,6 +85,7 @@ public class XmlWebApplicationContextTests extends AbstractApplicationContextTes
} }
@Test @Test
@SuppressWarnings("deprecation")
public void environmentMerge() { public void environmentMerge() {
assertThat(this.root.getEnvironment().acceptsProfiles("rootProfile1"), is(true)); assertThat(this.root.getEnvironment().acceptsProfiles("rootProfile1"), is(true));
assertThat(this.root.getEnvironment().acceptsProfiles("wacProfile1"), is(false)); assertThat(this.root.getEnvironment().acceptsProfiles("wacProfile1"), is(false));

View File

@@ -265,26 +265,6 @@ public class RequestMappingHandlerAdapterTests {
assertEquals(handlerCount, this.handlerAdapter.getReturnValueHandlers().size()); assertEquals(handlerCount, this.handlerAdapter.getReturnValueHandlers().size());
} }
private void testJsonp(String value, boolean validValue) throws Exception {
this.request = new MockHttpServletRequest("GET", "/");
this.request.addHeader("Accept", MediaType.APPLICATION_JSON_VALUE);
this.request.setParameter("c", value);
this.response = new MockHttpServletResponse();
HandlerMethod handlerMethod = handlerMethod(new SimpleController(), "handleWithResponseEntity");
this.handlerAdapter.afterPropertiesSet();
this.handlerAdapter.handle(this.request, this.response, handlerMethod);
assertEquals(200, this.response.getStatus());
if (validValue) {
assertEquals("/**/" + value + "({\"foo\":\"bar\"});", this.response.getContentAsString());
}
else {
assertEquals("{\"foo\":\"bar\"}", this.response.getContentAsString());
}
}
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static class SimpleController { private static class SimpleController {

View File

@@ -936,6 +936,7 @@ public class RequestResponseBodyMethodProcessorTests {
@RequestMapping @RequestMapping
@ResponseBody @ResponseBody
@SuppressWarnings("unchecked")
public List<T> handleTypeInfoList() { public List<T> handleTypeInfoList() {
List<T> list = new ArrayList<>(); List<T> list = new ArrayList<>();
list.add((T) new Foo("foo")); list.add((T) new Foo("foo"));

View File

@@ -13,4 +13,4 @@ fun ScriptTemplateWithBindings.i18n(code: String) =
var ScriptTemplateWithBindings.foo: String var ScriptTemplateWithBindings.foo: String
get() = bindings["foo"] as String get() = bindings["foo"] as String
set(value) { throw UnsupportedOperationException()} set(@Suppress("UNUSED_PARAMETER") value) { throw UnsupportedOperationException()}

View File

@@ -679,6 +679,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
private final List<WebSocketHandlerDecoratorFactory> factories; private final List<WebSocketHandlerDecoratorFactory> factories;
@SuppressWarnings("unused")
public DecoratingFactoryBean(WebSocketHandler handler, List<WebSocketHandlerDecoratorFactory> factories) { public DecoratingFactoryBean(WebSocketHandler handler, List<WebSocketHandlerDecoratorFactory> factories) {
this.handler = handler; this.handler = handler;
this.factories = factories; this.factories = factories;

View File

@@ -18,7 +18,6 @@ package org.springframework.web.socket.sockjs.transport.handler;
import org.junit.Test; import org.junit.Test;
import org.springframework.http.MediaType;
import org.springframework.web.socket.AbstractHttpRequestTests; import org.springframework.web.socket.AbstractHttpRequestTests;
import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketHandler; import org.springframework.web.socket.WebSocketHandler;