Clean up warnings

This commit is contained in:
Sam Brannen 2019-05-11 15:51:06 +02:00
parent 64819bbc1d
commit 6ef7d7124e
29 changed files with 91 additions and 53 deletions

View File

@ -837,7 +837,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
PropertyTokenHolder tokens = getPropertyNameTokens(nestedProperty); PropertyTokenHolder tokens = getPropertyNameTokens(nestedProperty);
String canonicalName = tokens.canonicalName; String canonicalName = tokens.canonicalName;
Object value = getPropertyValue(tokens); Object value = getPropertyValue(tokens);
if (value == null || (value instanceof Optional && !((Optional) value).isPresent())) { if (value == null || (value instanceof Optional && !((Optional<?>) value).isPresent())) {
if (isAutoGrowNestedPaths()) { if (isAutoGrowNestedPaths()) {
value = setDefaultValue(tokens); value = setDefaultValue(tokens);
} }

View File

@ -523,8 +523,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
protected boolean determineRequiredStatus(MergedAnnotation<?> ann) { protected boolean determineRequiredStatus(MergedAnnotation<?> ann) {
return determineRequiredStatus((AnnotationAttributes) return determineRequiredStatus(ann.asMap(mergedAnnotation -> new AnnotationAttributes(mergedAnnotation.getType())));
ann.asMap(mergedAnnotation -> new AnnotationAttributes(mergedAnnotation.getType())));
} }
/** /**

View File

@ -229,6 +229,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
* @return the number of bean definitions found * @return the number of bean definitions found
* @throws BeanDefinitionStoreException in case of loading or parsing errors * @throws BeanDefinitionStoreException in case of loading or parsing errors
*/ */
@SuppressWarnings("rawtypes")
public int loadBeanDefinitions(EncodedResource encodedResource) throws BeanDefinitionStoreException { public int loadBeanDefinitions(EncodedResource encodedResource) throws BeanDefinitionStoreException {
// Check for XML files and redirect them to the "standard" XmlBeanDefinitionReader // Check for XML files and redirect them to the "standard" XmlBeanDefinitionReader
String filename = encodedResource.getResource().getFilename(); String filename = encodedResource.getResource().getFilename();
@ -242,7 +243,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
Closure beans = new Closure(this) { Closure beans = new Closure(this) {
@Override @Override
public Object call(Object[] args) { public Object call(Object... args) {
invokeBeanDefiningClosure((Closure) args[0]); invokeBeanDefiningClosure((Closure) args[0]);
return null; return null;
} }
@ -285,6 +286,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
* @param closure the block or closure * @param closure the block or closure
* @return this {@code GroovyBeanDefinitionReader} instance * @return this {@code GroovyBeanDefinitionReader} instance
*/ */
@SuppressWarnings("rawtypes")
public GroovyBeanDefinitionReader beans(Closure closure) { public GroovyBeanDefinitionReader beans(Closure closure) {
return invokeBeanDefiningClosure(closure); return invokeBeanDefiningClosure(closure);
} }
@ -306,6 +308,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
* @param args the constructors arguments and closure configurer * @param args the constructors arguments and closure configurer
* @return the bean definition * @return the bean definition
*/ */
@SuppressWarnings("rawtypes")
public AbstractBeanDefinition bean(Class<?> type, Object...args) { public AbstractBeanDefinition bean(Class<?> type, Object...args) {
GroovyBeanDefinitionWrapper current = this.currentBeanDefinition; GroovyBeanDefinitionWrapper current = this.currentBeanDefinition;
try { try {
@ -373,6 +376,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
* This method overrides method invocation to create beans for each method name that * This method overrides method invocation to create beans for each method name that
* takes a class argument. * takes a class argument.
*/ */
@SuppressWarnings("rawtypes")
public Object invokeMethod(String name, Object arg) { public Object invokeMethod(String name, Object arg) {
Object[] args = (Object[])arg; Object[] args = (Object[])arg;
if ("beans".equals(name) && args.length == 1 && args[0] instanceof Closure) { if ("beans".equals(name) && args.length == 1 && args[0] instanceof Closure) {
@ -426,6 +430,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
return false; return false;
} }
@SuppressWarnings("rawtypes")
private void finalizeDeferredProperties() { private void finalizeDeferredProperties() {
for (DeferredProperty dp : this.deferredProperties.values()) { for (DeferredProperty dp : this.deferredProperties.values()) {
if (dp.value instanceof List) { if (dp.value instanceof List) {
@ -444,6 +449,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
* @param callable the closure argument * @param callable the closure argument
* @return this {@code GroovyBeanDefinitionReader} instance * @return this {@code GroovyBeanDefinitionReader} instance
*/ */
@SuppressWarnings("rawtypes")
protected GroovyBeanDefinitionReader invokeBeanDefiningClosure(Closure callable) { protected GroovyBeanDefinitionReader invokeBeanDefiningClosure(Closure callable) {
callable.setDelegate(this); callable.setDelegate(this);
callable.call(); callable.call();
@ -458,6 +464,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
* argument is sometimes a closure. All the arguments in between are constructor arguments. * argument is sometimes a closure. All the arguments in between are constructor arguments.
* @return the bean definition wrapper * @return the bean definition wrapper
*/ */
@SuppressWarnings("rawtypes")
private GroovyBeanDefinitionWrapper invokeBeanDefiningMethod(String beanName, Object[] args) { private GroovyBeanDefinitionWrapper invokeBeanDefiningMethod(String beanName, Object[] args) {
boolean hasClosureArgument = (args[args.length - 1] instanceof Closure); boolean hasClosureArgument = (args[args.length - 1] instanceof Closure);
if (args[0] instanceof Class) { if (args[0] instanceof Class) {
@ -483,9 +490,9 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
else if (args[0] instanceof Map) { else if (args[0] instanceof Map) {
// named constructor arguments // named constructor arguments
if (args.length > 1 && args[1] instanceof Class) { if (args.length > 1 && args[1] instanceof Class) {
List constructorArgs = resolveConstructorArguments(args, 2, hasClosureArgument ? args.length - 1 : args.length); List<Object> constructorArgs = resolveConstructorArguments(args, 2, hasClosureArgument ? args.length - 1 : args.length);
this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(beanName, (Class)args[1], constructorArgs); this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(beanName, (Class<?>) args[1], constructorArgs);
Map namedArgs = (Map)args[0]; Map namedArgs = (Map) args[0];
for (Object o : namedArgs.keySet()) { for (Object o : namedArgs.keySet()) {
String propName = (String) o; String propName = (String) o;
setProperty(propName, namedArgs.get(propName)); setProperty(propName, namedArgs.get(propName));
@ -494,7 +501,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
// factory method syntax // factory method syntax
else { else {
this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(beanName); this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(beanName);
//First arg is the map containing factoryBean : factoryMethod // First arg is the map containing factoryBean : factoryMethod
Map.Entry factoryBeanEntry = (Map.Entry) ((Map) args[0]).entrySet().iterator().next(); Map.Entry factoryBeanEntry = (Map.Entry) ((Map) args[0]).entrySet().iterator().next();
// If we have a closure body, that will be the last argument. // If we have a closure body, that will be the last argument.
// In between are the constructor args // In between are the constructor args
@ -537,6 +544,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
return beanDefinition; return beanDefinition;
} }
@SuppressWarnings("rawtypes")
protected List<Object> resolveConstructorArguments(Object[] args, int start, int end) { protected List<Object> resolveConstructorArguments(Object[] args, int start, int end) {
Object[] constructorArgs = Arrays.copyOfRange(args, start, end); Object[] constructorArgs = Arrays.copyOfRange(args, start, end);
for (int i = 0; i < constructorArgs.length; i++) { for (int i = 0; i < constructorArgs.length; i++) {
@ -607,6 +615,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
} }
} }
@SuppressWarnings("rawtypes")
protected void applyPropertyToBeanDefinition(String name, Object value) { protected void applyPropertyToBeanDefinition(String name, Object value) {
if (value instanceof GString) { if (value instanceof GString) {
value = value.toString(); value = value.toString();
@ -785,7 +794,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
/** /**
* Wraps a bean definition property an ensures that any RuntimeBeanReference * Wraps a bean definition property and ensures that any RuntimeBeanReference
* additions to it are deferred for resolution later. * additions to it are deferred for resolution later.
*/ */
private class GroovyPropertyValue extends GroovyObjectSupport { private class GroovyPropertyValue extends GroovyObjectSupport {
@ -799,17 +808,20 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
this.propertyValue = propertyValue; this.propertyValue = propertyValue;
} }
@SuppressWarnings("unused")
public void leftShift(Object value) { public void leftShift(Object value) {
InvokerHelper.invokeMethod(this.propertyValue, "leftShift", value); InvokerHelper.invokeMethod(this.propertyValue, "leftShift", value);
updateDeferredProperties(value); updateDeferredProperties(value);
} }
@SuppressWarnings("unused")
public boolean add(Object value) { public boolean add(Object value) {
boolean retVal = (Boolean) InvokerHelper.invokeMethod(this.propertyValue, "add", value); boolean retVal = (Boolean) InvokerHelper.invokeMethod(this.propertyValue, "add", value);
updateDeferredProperties(value); updateDeferredProperties(value);
return retVal; return retVal;
} }
@SuppressWarnings({ "rawtypes", "unused" })
public boolean addAll(Collection values) { public boolean addAll(Collection values) {
boolean retVal = (Boolean) InvokerHelper.invokeMethod(this.propertyValue, "addAll", values); boolean retVal = (Boolean) InvokerHelper.invokeMethod(this.propertyValue, "addAll", values);
for (Object value : values) { for (Object value : values) {

View File

@ -173,6 +173,7 @@ class GroovyBeanDefinitionWrapper extends GroovyObjectSupport {
} }
@Override @Override
@SuppressWarnings("rawtypes")
public void setProperty(String property, Object newValue) { public void setProperty(String property, Object newValue) {
if (PARENT.equals(property)) { if (PARENT.equals(property)) {
setParent(newValue); setParent(newValue);

View File

@ -1142,6 +1142,7 @@ public abstract class AbstractPropertyAccessorTests {
} }
@Test @Test
@SuppressWarnings("rawtypes")
public void setGenericArrayProperty() { public void setGenericArrayProperty() {
SkipReaderStub target = new SkipReaderStub(); SkipReaderStub target = new SkipReaderStub();
AbstractPropertyAccessor accessor = createAccessor(target); AbstractPropertyAccessor accessor = createAccessor(target);
@ -1459,7 +1460,7 @@ public abstract class AbstractPropertyAccessorTests {
assertEquals("rob", ((TestBean) target.getMap().get(2)).getName()); assertEquals("rob", ((TestBean) target.getMap().get(2)).getName());
} }
@SuppressWarnings("unchecked") // must work with raw map in this test @SuppressWarnings({ "unchecked", "rawtypes" }) // must work with raw map in this test
@Test @Test
public void setRawMapPropertyWithNoEditorRegistered() { public void setRawMapPropertyWithNoEditorRegistered() {
IndexedTestBean target = new IndexedTestBean(); IndexedTestBean target = new IndexedTestBean();
@ -1787,6 +1788,7 @@ public abstract class AbstractPropertyAccessorTests {
} }
@SuppressWarnings("unused")
private static class Simple { private static class Simple {
private String name; private String name;
@ -1815,6 +1817,7 @@ public abstract class AbstractPropertyAccessorTests {
} }
} }
@SuppressWarnings("unused")
private static class Person { private static class Person {
private String name; private String name;
@ -1845,6 +1848,7 @@ public abstract class AbstractPropertyAccessorTests {
} }
} }
@SuppressWarnings("unused")
private static class Address { private static class Address {
private String city; private String city;
@ -1876,6 +1880,7 @@ public abstract class AbstractPropertyAccessorTests {
} }
} }
@SuppressWarnings("unused")
private static class Country { private static class Country {
private String name; private String name;
@ -1904,7 +1909,7 @@ public abstract class AbstractPropertyAccessorTests {
} }
} }
@SuppressWarnings("unused") @SuppressWarnings({ "unused", "rawtypes" })
private static class Foo { private static class Foo {
private List list; private List list;
@ -2200,10 +2205,12 @@ public abstract class AbstractPropertyAccessorTests {
public SkipReaderStub() { public SkipReaderStub() {
} }
@SuppressWarnings("unchecked")
public SkipReaderStub(T... items) { public SkipReaderStub(T... items) {
this.items = items; this.items = items;
} }
@SuppressWarnings("unchecked")
public void setItems(T... items) { public void setItems(T... items) {
this.items = items; this.items = items;
} }
@ -2237,6 +2244,7 @@ public abstract class AbstractPropertyAccessorTests {
} }
@Override @Override
@SuppressWarnings("unchecked")
public Spr13837Bean setSomething(final Integer something) { public Spr13837Bean setSomething(final Integer something) {
this.something = something; this.something = something;
return this; return this;

View File

@ -164,6 +164,7 @@ public class BeanWrapperAutoGrowingTests {
} }
@SuppressWarnings("rawtypes")
public static class Bean { public static class Bean {
private String prop; private String prop;

View File

@ -160,7 +160,7 @@ public class BeanWrapperGenericsTests {
GenericBean<?> gb = new GenericBean<>(); GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb); BeanWrapper bw = new BeanWrapperImpl(gb);
bw.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, false)); bw.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, false));
Map<String, Collection> input = new HashMap<>(); Map<String, Collection<?>> input = new HashMap<>();
HashSet<Integer> value1 = new HashSet<>(); HashSet<Integer> value1 = new HashSet<>();
value1.add(new Integer(1)); value1.add(new Integer(1));
input.put("1", value1); input.put("1", value1);
@ -507,6 +507,7 @@ public class BeanWrapperGenericsTests {
public Holder(D data) { public Holder(D data) {
this.data = data; this.data = data;
} }
@SuppressWarnings("unused")
public D getData() { public D getData() {
return this.data; return this.data;
} }

View File

@ -176,6 +176,7 @@ public class BeanWrapperTests extends AbstractPropertyAccessorTests {
} }
@Test @Test
@SuppressWarnings("unchecked")
public void getPropertyWithOptional() { public void getPropertyWithOptional() {
GetterWithOptional target = new GetterWithOptional(); GetterWithOptional target = new GetterWithOptional();
TestBean tb = new TestBean("x"); TestBean tb = new TestBean("x");

View File

@ -124,6 +124,7 @@ public class PropertyMatchesTests {
} }
@SuppressWarnings("unused")
private static class SampleBeanProperties { private static class SampleBeanProperties {
private String name; private String name;
@ -178,6 +179,7 @@ public class PropertyMatchesTests {
} }
@SuppressWarnings("unused")
private static class SampleFieldProperties { private static class SampleFieldProperties {
private String name; private String name;

View File

@ -1464,6 +1464,7 @@ public class DefaultListableBeanFactoryTests {
} }
@Test @Test
@SuppressWarnings("rawtypes")
public void testGetFactoryBeanByTypeWithPrimary() { public void testGetFactoryBeanByTypeWithPrimary() {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
RootBeanDefinition bd1 = new RootBeanDefinition(NullTestBeanFactoryBean.class); RootBeanDefinition bd1 = new RootBeanDefinition(NullTestBeanFactoryBean.class);
@ -1814,6 +1815,7 @@ public class DefaultListableBeanFactoryTests {
} }
@Test @Test
@SuppressWarnings("rawtypes")
public void testBeanProviderSerialization() throws Exception { public void testBeanProviderSerialization() throws Exception {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
lbf.setSerializationId("test"); lbf.setSerializationId("test");
@ -2674,10 +2676,6 @@ public class DefaultListableBeanFactoryTests {
public Object postProcessBeforeInitialization(Object bean, String beanName) { public Object postProcessBeforeInitialization(Object bean, String beanName) {
return new TestBean(); return new TestBean();
} }
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) {
return bean;
}
}); });
BeanWithDisposableBean.closed = false; BeanWithDisposableBean.closed = false;
lbf.preInstantiateSingletons(); lbf.preInstantiateSingletons();
@ -2695,10 +2693,6 @@ public class DefaultListableBeanFactoryTests {
public Object postProcessBeforeInitialization(Object bean, String beanName) { public Object postProcessBeforeInitialization(Object bean, String beanName) {
return new TestBean(); return new TestBean();
} }
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) {
return bean;
}
}); });
BeanWithDisposableBean.closed = false; BeanWithDisposableBean.closed = false;
lbf.preInstantiateSingletons(); lbf.preInstantiateSingletons();
@ -2717,10 +2711,6 @@ public class DefaultListableBeanFactoryTests {
public Object postProcessBeforeInitialization(Object bean, String beanName) { public Object postProcessBeforeInitialization(Object bean, String beanName) {
return new TestBean(); return new TestBean();
} }
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) {
return bean;
}
}); });
BeanWithDestroyMethod.closeCount = 0; BeanWithDestroyMethod.closeCount = 0;
lbf.preInstantiateSingletons(); lbf.preInstantiateSingletons();
@ -2943,7 +2933,7 @@ public class DefaultListableBeanFactoryTests {
} }
@Test @Test
@SuppressWarnings("unchecked") @SuppressWarnings({ "unchecked", "rawtypes" })
public void testInitSecurityAwarePrototypeBean() { public void testInitSecurityAwarePrototypeBean() {
final DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); final DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
RootBeanDefinition bd = new RootBeanDefinition(TestSecuredBean.class); RootBeanDefinition bd = new RootBeanDefinition(TestSecuredBean.class);
@ -3202,6 +3192,7 @@ public class DefaultListableBeanFactoryTests {
private static int closeCount = 0; private static int closeCount = 0;
@SuppressWarnings("unused")
private BeanWithDestroyMethod inner; private BeanWithDestroyMethod inner;
public void setInner(BeanWithDestroyMethod inner) { public void setInner(BeanWithDestroyMethod inner) {
@ -3416,7 +3407,7 @@ public class DefaultListableBeanFactoryTests {
} }
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings({ "unchecked", "rawtypes" })
public Object convertIfNecessary(Object value, @Nullable Class requiredType) { public Object convertIfNecessary(Object value, @Nullable Class requiredType) {
if (value instanceof String && Float.class.isAssignableFrom(requiredType)) { if (value instanceof String && Float.class.isAssignableFrom(requiredType)) {
try { try {
@ -3435,13 +3426,13 @@ public class DefaultListableBeanFactoryTests {
} }
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings({ "unchecked", "rawtypes" })
public Object convertIfNecessary(Object value, @Nullable Class requiredType, @Nullable MethodParameter methodParam) { public Object convertIfNecessary(Object value, @Nullable Class requiredType, @Nullable MethodParameter methodParam) {
return convertIfNecessary(value, requiredType); return convertIfNecessary(value, requiredType);
} }
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings({ "unchecked", "rawtypes" })
public Object convertIfNecessary(Object value, @Nullable Class requiredType, @Nullable Field field) { public Object convertIfNecessary(Object value, @Nullable Class requiredType, @Nullable Field field) {
return convertIfNecessary(value, requiredType); return convertIfNecessary(value, requiredType);
} }
@ -3564,6 +3555,7 @@ public class DefaultListableBeanFactoryTests {
public TestBean testBean; public TestBean testBean;
@SuppressWarnings("unused")
public TestBeanRecipient(TestBean testBean) { public TestBeanRecipient(TestBean testBean) {
this.testBean = testBean; this.testBean = testBean;
} }

View File

@ -95,7 +95,7 @@ public class CustomScopeConfigurerTests {
figurer.postProcessBeanFactory(factory); figurer.postProcessBeanFactory(factory);
} }
@SuppressWarnings("unchecked") @SuppressWarnings({ "unchecked", "rawtypes" })
@Test(expected = ClassCastException.class) @Test(expected = ClassCastException.class)
public void testWhereScopeMapHasNonStringTypedScopeNameInKeySet() { public void testWhereScopeMapHasNonStringTypedScopeNameInKeySet() {
Map scopes = new HashMap(); Map scopes = new HashMap();

View File

@ -73,6 +73,7 @@ public class ObjectFactoryCreatingFactoryBeanTests {
} }
@Test @Test
@SuppressWarnings("rawtypes")
public void testFactorySerialization() throws Exception { public void testFactorySerialization() throws Exception {
FactoryTestBean testBean = beanFactory.getBean("factoryTestBean", FactoryTestBean.class); FactoryTestBean testBean = beanFactory.getBean("factoryTestBean", FactoryTestBean.class);
ObjectFactory<?> objectFactory = testBean.getObjectFactory(); ObjectFactory<?> objectFactory = testBean.getObjectFactory();
@ -95,6 +96,7 @@ public class ObjectFactoryCreatingFactoryBeanTests {
} }
@Test @Test
@SuppressWarnings("rawtypes")
public void testProviderSerialization() throws Exception { public void testProviderSerialization() throws Exception {
ProviderTestBean testBean = beanFactory.getBean("providerTestBean", ProviderTestBean.class); ProviderTestBean testBean = beanFactory.getBean("providerTestBean", ProviderTestBean.class);
Provider<?> provider = testBean.getProvider(); Provider<?> provider = testBean.getProvider();

View File

@ -329,7 +329,7 @@ public class PropertyResourceConfigurerTests {
} }
private void doTestPropertyPlaceholderConfigurer(boolean parentChildSeparation) { private void doTestPropertyPlaceholderConfigurer(boolean parentChildSeparation) {
Map singletonMap = Collections.singletonMap("myKey", "myValue"); Map<String, String> singletonMap = Collections.singletonMap("myKey", "myValue");
if (parentChildSeparation) { if (parentChildSeparation) {
MutablePropertyValues pvs1 = new MutablePropertyValues(); MutablePropertyValues pvs1 = new MutablePropertyValues();
pvs1.add("age", "${age}"); pvs1.add("age", "${age}");

View File

@ -262,7 +262,7 @@ public class ServiceLocatorFactoryBeanTests {
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@SuppressWarnings("unchecked") @SuppressWarnings({ "unchecked", "rawtypes" })
public void testWhenServiceLocatorExceptionClassIsNotAnExceptionSubclass() throws Exception { public void testWhenServiceLocatorExceptionClassIsNotAnExceptionSubclass() throws Exception {
ServiceLocatorFactoryBean factory = new ServiceLocatorFactoryBean(); ServiceLocatorFactoryBean factory = new ServiceLocatorFactoryBean();
factory.setServiceLocatorExceptionClass((Class) getClass()); factory.setServiceLocatorExceptionClass((Class) getClass());

View File

@ -63,7 +63,7 @@ import static org.junit.Assert.fail;
* Security test case. Checks whether the container uses its privileges for its * Security test case. Checks whether the container uses its privileges for its
* internal work but does not leak them when touching/calling user code. * internal work but does not leak them when touching/calling user code.
* *
*t The first half of the test case checks that permissions are downgraded when * <p>The first half of the test case checks that permissions are downgraded when
* calling user code while the second half that the caller code permission get * calling user code while the second half that the caller code permission get
* through and Spring doesn't override the permission stack. * through and Spring doesn't override the permission stack.
* *
@ -162,7 +162,7 @@ public class CallbacksSecurityTests {
} }
} }
@SuppressWarnings("unused") @SuppressWarnings({ "unused", "rawtypes" })
private static class NonPrivilegedFactoryBean implements SmartFactoryBean { private static class NonPrivilegedFactoryBean implements SmartFactoryBean {
private String expectedName; private String expectedName;
@ -557,4 +557,5 @@ public class CallbacksSecurityTests {
} }
}, provider.getAccessControlContext()); }, provider.getAccessControlContext());
} }
} }

View File

@ -13,6 +13,7 @@
* 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.beans.factory.support.security.support; package org.springframework.beans.factory.support.security.support;
import java.util.Properties; import java.util.Properties;
@ -22,15 +23,15 @@ import org.springframework.beans.factory.FactoryBean;
/** /**
* @author Costin Leau * @author Costin Leau
*/ */
public class CustomFactoryBean implements FactoryBean<Object> { public class CustomFactoryBean implements FactoryBean<Properties> {
@Override @Override
public Object getObject() throws Exception { public Properties getObject() throws Exception {
return System.getProperties(); return System.getProperties();
} }
@Override @Override
public Class getObjectType() { public Class<Properties> getObjectType() {
System.setProperty("factory.object.type", "true"); System.setProperty("factory.object.type", "true");
return Properties.class; return Properties.class;
} }
@ -39,4 +40,5 @@ public class CustomFactoryBean implements FactoryBean<Object> {
public boolean isSingleton() { public boolean isSingleton() {
return true; return true;
} }
} }

View File

@ -70,6 +70,7 @@ public class CollectionsWithDefaultTypesTests {
assertMap(bean.getSomeMap()); assertMap(bean.getSomeMap());
} }
@SuppressWarnings("rawtypes")
private void assertMap(Map<?,?> map) { private void assertMap(Map<?,?> map) {
for (Map.Entry entry : map.entrySet()) { for (Map.Entry entry : map.entrySet()) {
assertEquals("Key type is incorrect", Integer.class, entry.getKey().getClass()); assertEquals("Key type is incorrect", Integer.class, entry.getKey().getClass());
@ -78,6 +79,7 @@ public class CollectionsWithDefaultTypesTests {
} }
@Test @Test
@SuppressWarnings("rawtypes")
public void testBuildCollectionFromMixtureOfReferencesAndValues() throws Exception { public void testBuildCollectionFromMixtureOfReferencesAndValues() throws Exception {
MixedCollectionBean jumble = (MixedCollectionBean) this.beanFactory.getBean("jumble"); MixedCollectionBean jumble = (MixedCollectionBean) this.beanFactory.getBean("jumble");
assertTrue("Expected 3 elements, not " + jumble.getJumble().size(), assertTrue("Expected 3 elements, not " + jumble.getJumble().size(),

View File

@ -22,7 +22,7 @@ import org.springframework.tests.sample.beans.TestBean;
/** /**
* @author Juergen Hoeller * @author Juergen Hoeller
*/ */
public class CountingFactory implements FactoryBean { public class CountingFactory implements FactoryBean<String> {
private static int factoryBeanInstanceCount = 0; private static int factoryBeanInstanceCount = 0;
@ -51,12 +51,12 @@ public class CountingFactory implements FactoryBean {
@Override @Override
public Object getObject() { public String getObject() {
return "myString"; return "myString";
} }
@Override @Override
public Class getObjectType() { public Class<String> getObjectType() {
return String.class; return String.class;
} }

View File

@ -62,7 +62,7 @@ public class FactoryMethods {
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static List listInstance() { private static List<?> listInstance() {
return Collections.EMPTY_LIST; return Collections.EMPTY_LIST;
} }

View File

@ -27,14 +27,14 @@ import java.util.Collection;
*/ */
public class MixedCollectionBean { public class MixedCollectionBean {
private Collection jumble; private Collection<?> jumble;
public void setJumble(Collection jumble) { public void setJumble(Collection<?> jumble) {
this.jumble = jumble; this.jumble = jumble;
} }
public Collection getJumble() { public Collection<?> getJumble() {
return jumble; return jumble;
} }

View File

@ -91,6 +91,7 @@ public class NestedBeansElementAttributeRecursionTests {
assertMerge(bf); assertMerge(bf);
} }
@SuppressWarnings("unchecked")
private void assertMerge(DefaultListableBeanFactory bf) { private void assertMerge(DefaultListableBeanFactory bf) {
TestBean topLevel = bf.getBean("topLevelConcreteTestBean", TestBean.class); TestBean topLevel = bf.getBean("topLevelConcreteTestBean", TestBean.class);
// has the concrete child bean values // has the concrete child bean values

View File

@ -48,6 +48,7 @@ import static org.junit.Assert.assertTrue;
* @author Juergen Hoeller * @author Juergen Hoeller
* @author Mark Fisher * @author Mark Fisher
*/ */
@SuppressWarnings("rawtypes")
public class UtilNamespaceHandlerTests { public class UtilNamespaceHandlerTests {
private DefaultListableBeanFactory beanFactory; private DefaultListableBeanFactory beanFactory;

View File

@ -54,6 +54,7 @@ import static org.junit.Assert.fail;
* @author Chris Beams * @author Chris Beams
* @since 19.12.2004 * @since 19.12.2004
*/ */
@SuppressWarnings({ "rawtypes", "unchecked" })
public class XmlBeanCollectionTests { public class XmlBeanCollectionTests {
private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();

View File

@ -40,7 +40,7 @@ public class CustomCollectionEditorTests {
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@SuppressWarnings("unchecked") @SuppressWarnings({ "unchecked", "rawtypes" })
public void testCtorWithNonCollectionType() throws Exception { public void testCtorWithNonCollectionType() throws Exception {
new CustomCollectionEditor((Class) String.class); new CustomCollectionEditor((Class) String.class);
} }

View File

@ -38,6 +38,7 @@ import static org.junit.Assert.assertTrue;
public class PagedListHolderTests { public class PagedListHolderTests {
@Test @Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void testPagedListHolder() { public void testPagedListHolder() {
Assume.group(TestGroup.LONG_RUNNING); Assume.group(TestGroup.LONG_RUNNING);

View File

@ -92,6 +92,7 @@ public class PropertyComparatorTests {
} }
@SuppressWarnings("unused")
private static class Dog implements Comparable<Object> { private static class Dog implements Comparable<Object> {
private String nickName; private String nickName;

View File

@ -51,7 +51,7 @@ public class GenericBean<T> {
private List<Map<Integer, Long>> listOfMaps; private List<Map<Integer, Long>> listOfMaps;
private Map plainMap; private Map<?, ?> plainMap;
private Map<Short, Integer> shortMap; private Map<Short, Integer> shortMap;
@ -100,7 +100,7 @@ public class GenericBean<T> {
this.resourceList = Collections.singletonList(resource); this.resourceList = Collections.singletonList(resource);
} }
public GenericBean(Map plainMap, Map<Short, Integer> shortMap) { public GenericBean(Map<?, ?> plainMap, Map<Short, Integer> shortMap) {
this.plainMap = plainMap; this.plainMap = plainMap;
this.shortMap = shortMap; this.shortMap = shortMap;
} }
@ -178,7 +178,7 @@ public class GenericBean<T> {
this.listOfMaps = listOfMaps; this.listOfMaps = listOfMaps;
} }
public Map getPlainMap() { public Map<?, ?> getPlainMap() {
return plainMap; return plainMap;
} }
@ -289,30 +289,37 @@ public class GenericBean<T> {
this.standardEnumMap = standardEnumMap; this.standardEnumMap = standardEnumMap;
} }
@SuppressWarnings({ "rawtypes", "unchecked" })
public static GenericBean createInstance(Set<Integer> integerSet) { public static GenericBean createInstance(Set<Integer> integerSet) {
return new GenericBean(integerSet); return new GenericBean(integerSet);
} }
@SuppressWarnings({ "rawtypes", "unchecked" })
public static GenericBean createInstance(Set<Integer> integerSet, List<Resource> resourceList) { public static GenericBean createInstance(Set<Integer> integerSet, List<Resource> resourceList) {
return new GenericBean(integerSet, resourceList); return new GenericBean(integerSet, resourceList);
} }
@SuppressWarnings({ "rawtypes", "unchecked" })
public static GenericBean createInstance(HashSet<Integer> integerSet, Map<Short, Integer> shortMap) { public static GenericBean createInstance(HashSet<Integer> integerSet, Map<Short, Integer> shortMap) {
return new GenericBean(integerSet, shortMap); return new GenericBean(integerSet, shortMap);
} }
@SuppressWarnings({ "rawtypes", "unchecked" })
public static GenericBean createInstance(Map<Short, Integer> shortMap, Resource resource) { public static GenericBean createInstance(Map<Short, Integer> shortMap, Resource resource) {
return new GenericBean(shortMap, resource); return new GenericBean(shortMap, resource);
} }
@SuppressWarnings({ "rawtypes", "unchecked" })
public static GenericBean createInstance(Map map, Map<Short, Integer> shortMap) { public static GenericBean createInstance(Map map, Map<Short, Integer> shortMap) {
return new GenericBean(map, shortMap); return new GenericBean(map, shortMap);
} }
@SuppressWarnings({ "rawtypes", "unchecked" })
public static GenericBean createInstance(HashMap<Long, ?> longMap) { public static GenericBean createInstance(HashMap<Long, ?> longMap) {
return new GenericBean(longMap); return new GenericBean(longMap);
} }
@SuppressWarnings({ "rawtypes", "unchecked" })
public static GenericBean createInstance(boolean someFlag, Map<Number, Collection<? extends Object>> collectionMap) { public static GenericBean createInstance(boolean someFlag, Map<Number, Collection<? extends Object>> collectionMap) {
return new GenericBean(someFlag, collectionMap); return new GenericBean(someFlag, collectionMap);
} }

View File

@ -45,9 +45,9 @@ public class HasMap {
private List<Class<?>> classList; private List<Class<?>> classList;
private IdentityHashMap identityMap; private IdentityHashMap<?, ?> identityMap;
private CopyOnWriteArraySet concurrentSet; private CopyOnWriteArraySet<?> concurrentSet;
private HasMap() { private HasMap() {
} }
@ -108,19 +108,19 @@ public class HasMap {
this.classList = classList; this.classList = classList;
} }
public IdentityHashMap getIdentityMap() { public IdentityHashMap<?, ?> getIdentityMap() {
return identityMap; return identityMap;
} }
public void setIdentityMap(IdentityHashMap identityMap) { public void setIdentityMap(IdentityHashMap<?, ?> identityMap) {
this.identityMap = identityMap; this.identityMap = identityMap;
} }
public CopyOnWriteArraySet getConcurrentSet() { public CopyOnWriteArraySet<?> getConcurrentSet() {
return concurrentSet; return concurrentSet;
} }
public void setConcurrentSet(CopyOnWriteArraySet concurrentSet) { public void setConcurrentSet(CopyOnWriteArraySet<?> concurrentSet) {
this.concurrentSet = concurrentSet; this.concurrentSet = concurrentSet;
} }

View File

@ -30,6 +30,7 @@ import java.util.TreeSet;
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 11.11.2003 * @since 11.11.2003
*/ */
@SuppressWarnings("rawtypes")
public class IndexedTestBean { public class IndexedTestBean {
private TestBean[] array; private TestBean[] array;
@ -57,6 +58,7 @@ public class IndexedTestBean {
} }
} }
@SuppressWarnings("unchecked")
public void populate() { public void populate() {
TestBean tb0 = new TestBean("name0", 0); TestBean tb0 = new TestBean("name0", 0);
TestBean tb1 = new TestBean("name1", 0); TestBean tb1 = new TestBean("name1", 0);