Skip to content

Commit

Permalink
Clean up warnings and delete dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Aug 12, 2018
1 parent c4a7567 commit cfb1ed1
Show file tree
Hide file tree
Showing 25 changed files with 25 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ public void asyncAspectRegistered() {
}

@Test
@SuppressWarnings("rawtypes")
public void asyncPostProcessorExecutorReference() {
Object executor = context.getBean("testExecutor");
Object aspect = context.getBean(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME);
assertSame(executor, ((Supplier) new DirectFieldAccessor(aspect).getPropertyValue("defaultExecutor")).get());
}

@Test
@SuppressWarnings("rawtypes")
public void asyncPostProcessorExceptionHandlerReference() {
Object exceptionHandler = context.getBean("testExceptionHandler");
Object aspect = context.getBean(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ public void testListValidation() {
errors.initConversion(new DefaultConversionService());
validator.validate(listContainer, errors);

FieldError fieldError = errors.getFieldError("list[1]");
assertEquals("X", errors.getFieldValue("list[1]"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.SubscribableChannel;
import org.springframework.messaging.converter.MessageConverter;
import org.springframework.messaging.handler.HandlerMethod;
Expand Down Expand Up @@ -267,9 +266,9 @@ public void dotPathSeparator() {
}

@Test
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
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.converter.toMessage(any(), any(MessageHeaders.class))).willReturn(emptyMessage);

Expand All @@ -287,9 +286,9 @@ public void listenableFutureSuccess() {
}

@Test
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
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.converter.toMessage(any(), any(MessageHeaders.class))).willReturn(emptyMessage);

Expand All @@ -305,9 +304,9 @@ public void listenableFutureFailure() {
}

@Test
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
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.converter.toMessage(any(), any(MessageHeaders.class))).willReturn(emptyMessage);

Expand All @@ -325,9 +324,9 @@ public void completableFutureSuccess() {
}

@Test
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
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.converter.toMessage(any(), any(MessageHeaders.class))).willReturn(emptyMessage);

Expand All @@ -343,6 +342,7 @@ public void completableFutureFailure() {
}

@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void monoSuccess() {
Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build();
given(this.channel.send(any(Message.class))).willReturn(true);
Expand All @@ -362,6 +362,7 @@ public void monoSuccess() {
}

@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void monoFailure() {
Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build();
given(this.channel.send(any(Message.class))).willReturn(true);
Expand All @@ -379,6 +380,7 @@ public void monoFailure() {
}

@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void fluxNotHandled() {
Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build();
given(this.channel.send(any(Message.class))).willReturn(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void testJdbcTx2() {
public void testEntityManagerProxyIsProxy() {
assertTrue(Proxy.isProxyClass(sharedEntityManager.getClass()));
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());
sharedEntityManager.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionException;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void testEntityListener() {
}

@Test
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testCurrentSession() {
String firstName = "Tony";
insertPerson(firstName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.w3c.dom.Text;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;

import org.springframework.util.xml.StaxUtils;

Expand Down Expand Up @@ -98,8 +97,9 @@ public void unmarshalStreamSourceInputStream() throws Exception {
}

@Test
@SuppressWarnings("deprecation")
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)));
Object flights = unmarshaller.unmarshal(source);
testFlights(flights);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.http;

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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.apache.commons.fileupload.FileUpload;
import org.apache.commons.fileupload.RequestContext;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.hamcrest.CoreMatchers;
import org.hamcrest.Matchers;
import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
import org.springframework.mock.web.test.server.MockServerWebExchange;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.util.pattern.PathPatternParser;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,9 @@
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import org.junit.Test;

import org.springframework.web.util.UriComponents.UriTemplateVariables;

import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.not;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import java.util.List;
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.Mono;

Expand Down Expand Up @@ -74,8 +72,6 @@ public class DispatcherHandler implements WebHandler, ApplicationContextAware {
new ResponseStatusException(HttpStatus.NOT_FOUND, "No matching handler");


private static final Log logger = LogFactory.getLog(DispatcherHandler.class);

@Nullable
private List<HandlerMapping> handlerMappings;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
import org.springframework.util.MultiValueMap;

import static org.junit.Assert.*;
import static org.mockito.Mockito.when;
import static org.springframework.http.codec.json.Jackson2CodecSupport.*;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;

import org.springframework.core.NamedInheritableThreadLocal;
import org.springframework.core.NamedThreadLocal;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public void headers() {
}

@Test
@SuppressWarnings("unchecked")
public void cookies() {
MultiValueMap<String, ResponseCookie> cookies = mock(MultiValueMap.class);
when(mockResponse.cookies()).thenReturn(cookies);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public void pathVariables() {
}

@Test
@SuppressWarnings("unchecked")
public void cookies() {
MultiValueMap<String, HttpCookie> cookies = mock(MultiValueMap.class);
when(mockRequest.cookies()).thenReturn(cookies);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.Locale;
import java.util.TimeZone;

import org.junit.Before;
import org.junit.Test;
import reactor.core.publisher.Mono;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ fun ScriptTemplateWithBindings.i18n(code: String) =

var ScriptTemplateWithBindings.foo: String
get() = bindings["foo"] as String
set(value) { throw UnsupportedOperationException() }
set(@Suppress("UNUSED_PARAMETER") value) { throw UnsupportedOperationException() }
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
import javax.servlet.ServletRequest;
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.ReactiveAdapterRegistry;
import org.springframework.core.ResolvableType;
Expand Down Expand Up @@ -60,9 +57,6 @@
*/
public class ResponseBodyEmitterReturnValueHandler implements HandlerMethodReturnValueHandler {

private static final Log logger = LogFactory.getLog(ResponseBodyEmitterReturnValueHandler.class);


private final List<HttpMessageConverter<?>> messageConverters;

private final ReactiveTypeHandler reactiveHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public Object postProcessAfterInitialization(Object bean, String name) throws Be
}

@Test
@SuppressWarnings("deprecation")
public void environmentMerge() {
assertThat(this.root.getEnvironment().acceptsProfiles("rootProfile1"), is(true));
assertThat(this.root.getEnvironment().acceptsProfiles("wacProfile1"), is(false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,26 +265,6 @@ private void assertMethodProcessorCount(int resolverCount, int initBinderResolve
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")
private static class SimpleController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ private static class BaseController<T> {

@RequestMapping
@ResponseBody
@SuppressWarnings("unchecked")
public List<T> handleTypeInfoList() {
List<T> list = new ArrayList<>();
list.add((T) new Foo("foo"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ fun ScriptTemplateWithBindings.i18n(code: String) =

var ScriptTemplateWithBindings.foo: String
get() = bindings["foo"] as String
set(value) { throw UnsupportedOperationException()}
set(@Suppress("UNUSED_PARAMETER") value) { throw UnsupportedOperationException()}
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ private static final class DecoratingFactoryBean implements FactoryBean<WebSocke

private final List<WebSocketHandlerDecoratorFactory> factories;

@SuppressWarnings("unused")
public DecoratingFactoryBean(WebSocketHandler handler, List<WebSocketHandlerDecoratorFactory> factories) {
this.handler = handler;
this.factories = factories;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import org.junit.Test;

import org.springframework.http.MediaType;
import org.springframework.web.socket.AbstractHttpRequestTests;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketHandler;
Expand Down

0 comments on commit cfb1ed1

Please sign in to comment.