Clean up warnings

This commit is contained in:
Sam Brannen 2019-05-10 18:00:29 +02:00
parent 0cff7eb32c
commit 64819bbc1d
13 changed files with 19 additions and 13 deletions

View File

@ -107,7 +107,7 @@ class KeyGeneratorAdapter implements KeyGenerator {
Object value = param.getValue();
if (param.getParameterPosition() == context.getAllParameters().length - 1 &&
context.getMethod().isVarArgs()) {
parameters.addAll((List<Object>) CollectionUtils.arrayToList(value));
parameters.addAll(CollectionUtils.arrayToList(value));
}
else {
parameters.add(value);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2019 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.
@ -21,6 +21,7 @@ import java.lang.reflect.InvocationTargetException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
@ -164,7 +165,6 @@ public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethod
@Override
@SuppressWarnings("unchecked")
public void afterPropertiesSet() throws ClassNotFoundException, NoSuchMethodException {
prepare();
@ -172,13 +172,13 @@ public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethod
String name = (this.name != null ? this.name : this.beanName);
// Consider the concurrent flag to choose between stateful and stateless job.
Class<?> jobClass = (this.concurrent ? MethodInvokingJob.class : StatefulMethodInvokingJob.class);
Class<? extends Job> jobClass = (this.concurrent ? MethodInvokingJob.class : StatefulMethodInvokingJob.class);
// Build JobDetail instance.
JobDetailImpl jdi = new JobDetailImpl();
jdi.setName(name != null ? name : toString());
jdi.setGroup(this.group);
jdi.setJobClass((Class) jobClass);
jdi.setJobClass(jobClass);
jdi.setDurability(true);
jdi.getJobDataMap().put("methodInvoker", this);
this.jobDetail = jdi;

View File

@ -97,7 +97,7 @@ public class JCacheCacheManagerTests extends AbstractTransactionSupportingCacheM
return cacheManager;
}
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
public void addCache(String name) {
cacheNames.add(name);
Cache cache = mock(Cache.class);

View File

@ -74,6 +74,7 @@ public class JCacheJavaConfigTests extends AbstractJCacheAnnotationTests {
cos.getExceptionCacheResolver());
JCacheInterceptor interceptor = context.getBean(JCacheInterceptor.class);
assertSame(context.getBean("errorHandler", CacheErrorHandler.class), interceptor.getErrorHandler());
context.close();
}
@Test

View File

@ -59,6 +59,7 @@ public class CacheResolverAdapterTests extends AbstractJCacheTests {
adapter.resolveCaches(dummyContext));
}
@SuppressWarnings({ "rawtypes", "unchecked" })
protected CacheResolver getCacheResolver(CacheInvocationContext<? extends Annotation> context, String cacheName) {
CacheResolver cacheResolver = mock(CacheResolver.class);
javax.cache.Cache cache;

View File

@ -66,6 +66,7 @@ public class JCacheErrorHandlerTests {
this.errorCache = context.getBean("mockErrorCache", Cache.class);
this.errorHandler = context.getBean(CacheErrorHandler.class);
this.simpleService = context.getBean(SimpleService.class);
context.close();
}

View File

@ -43,7 +43,6 @@ import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
*
* @author Stephane Nicoll
*/
public class JCacheKeyGeneratorTests {
@ -60,6 +59,7 @@ public class JCacheKeyGeneratorTests {
this.keyGenerator = context.getBean(TestKeyGenerator.class);
this.simpleService = context.getBean(SimpleService.class);
this.cache = context.getBean(CacheManager.class).getCache("test");
context.close();
}
@Test

View File

@ -32,6 +32,7 @@ public class TestableCacheResolver implements CacheResolver {
@Override
public <K, V> Cache<K, V> resolveCache(CacheInvocationContext<? extends Annotation> cacheInvocationContext) {
String cacheName = cacheInvocationContext.getCacheName();
@SuppressWarnings("unchecked")
Cache<K, V> mock = mock(Cache.class);
given(mock.getName()).willReturn(cacheName);
return mock;

View File

@ -63,9 +63,11 @@ import static org.junit.Assert.fail;
/**
* @author Juergen Hoeller
*/
@SuppressWarnings("resource")
public class ValidatorFactoryTests {
@Test
@SuppressWarnings("cast")
public void testSimpleValidation() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.afterPropertiesSet();
@ -92,6 +94,7 @@ public class ValidatorFactoryTests {
}
@Test
@SuppressWarnings("cast")
public void testSimpleValidationWithCustomProvider() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.setProviderClass(HibernateValidator.class);

View File

@ -873,10 +873,6 @@ public abstract class DataBufferUtils {
return -1;
}
public void reset() {
this.matches = 0;
}
@Override
public byte[] delimiter() {
return Arrays.copyOf(this.delimiter, this.delimiter.length);

View File

@ -18,6 +18,7 @@ package org.springframework.orm.jpa.hibernate.beans;
public class NoDefinitionInSpringContextTestBean extends TestBean {
@SuppressWarnings("unused")
private NoDefinitionInSpringContextTestBean() {
throw new AssertionError("Unexpected call to the default constructor. " +
"Is Spring trying to instantiate this class by itself, even though it should delegate to the fallback producer?"

View File

@ -258,7 +258,7 @@ final class DefaultEntityResponseBuilder<T> implements EntityResponse.Builder<T>
return null;
}
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "resource" })
protected void writeEntityWithMessageConverters(Object entity, HttpServletRequest request,
HttpServletResponse response, ServerResponse.Context context)
throws ServletException, IOException {

View File

@ -35,6 +35,8 @@ import static org.junit.Assert.fail;
import static org.springframework.web.servlet.function.RequestPredicates.HEAD;
/**
* Unit tests for {@link RouterFunctionBuilder}.
*
* @author Arjen Poutsma
*/
public class RouterFunctionBuilderTests {
@ -183,7 +185,7 @@ public class RouterFunctionBuilderTests {
MockHttpServletRequest servletRequest = new MockHttpServletRequest("GET", "/foo");
ServerRequest fooRequest = new DefaultServerRequest(servletRequest, emptyList());
Optional<ServerResponse> fooResponse = route.route(fooRequest)
route.route(fooRequest)
.map(handlerFunction -> handle(handlerFunction, fooRequest));
assertEquals(4, filterCount.get());