Clean up warnings

This commit is contained in:
Sam Brannen
2021-10-05 14:35:32 +02:00
parent be3bc4c164
commit 48a507a993
39 changed files with 92 additions and 84 deletions

View File

@@ -48,7 +48,6 @@ import org.springframework.core.NestedRuntimeException;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.lang.Nullable;
import org.springframework.util.StopWatch;
import static org.assertj.core.api.Assertions.assertThat;
@@ -310,12 +309,6 @@ public class AspectJAutoProxyCreatorTests {
return String.format("%s-%s", getClass().getSimpleName(), fileSuffix);
}
private void assertStopWatchTimeLimit(final StopWatch sw, final long maxTimeMillis) {
long totalTimeMillis = sw.getTotalTimeMillis();
assertThat(totalTimeMillis < maxTimeMillis).as("'" + sw.getLastTaskName() + "' took too long: expected less than<" + maxTimeMillis +
"> ms, actual<" + totalTimeMillis + "> ms.").isTrue();
}
}
@Aspect("pertarget(execution(* *.getSpouse()))")

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 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.
@@ -513,6 +513,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
this.name = name;
}
@SuppressWarnings("unused")
public String getName() {
return this.name;
}

View File

@@ -137,6 +137,7 @@ public class AggressiveFactoryBeanInstantiationTests {
static class ExceptionInInitializer {
@SuppressWarnings("unused")
private static final int ERROR = callInClinit();
private static int callInClinit() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 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.
@@ -1956,6 +1956,7 @@ class ConfigurationClassPostProcessorTests {
}
// Unrelated, not to be considered as a factory method
@SuppressWarnings("unused")
private boolean testBean(boolean param) {
return param;
}
@@ -1985,6 +1986,7 @@ class ConfigurationClassPostProcessorTests {
}
// Unrelated, not to be considered as a factory method
@SuppressWarnings("unused")
private boolean testBean(boolean param) {
return param;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 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.
@@ -61,7 +61,7 @@ public class ParserStrategyUtilsTests {
@BeforeEach
void setup() {
MockitoAnnotations.initMocks(this);
MockitoAnnotations.openMocks(this);
given(this.resourceLoader.getClassLoader()).willReturn(this.beanClassLoader);
}

View File

@@ -74,6 +74,7 @@ public class Spr12278Tests {
private final String autowiredName;
// No @Autowired - implicit wiring
@SuppressWarnings("unused")
public SingleConstructorComponent(String autowiredName) {
this.autowiredName = autowiredName;
}
@@ -88,11 +89,13 @@ public class Spr12278Tests {
this.name = name;
}
@SuppressWarnings("unused")
public TwoConstructorsComponent() {
this("fallback");
}
}
@SuppressWarnings("unused")
private static class TwoSpecificConstructorsComponent {
private final Integer counter;

View File

@@ -70,6 +70,7 @@ public class Spr16179Tests {
Assembler<Page<String>> assembler2;
@Autowired(required = false)
@SuppressWarnings("rawtypes")
Assembler<Page> assembler3;
@Autowired(required = false)

View File

@@ -42,7 +42,6 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.DependencyDescriptor;
import org.springframework.beans.factory.config.ListFactoryBean;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
@@ -247,7 +246,9 @@ public class ConfigurationClassProcessingTests {
public void configurationWithPostProcessor() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(ConfigWithPostProcessor.class);
RootBeanDefinition placeholderConfigurer = new RootBeanDefinition(PropertyPlaceholderConfigurer.class);
@SuppressWarnings("deprecation")
RootBeanDefinition placeholderConfigurer = new RootBeanDefinition(
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.class);
placeholderConfigurer.getPropertyValues().add("properties", "myProp=myValue");
ctx.registerBeanDefinition("placeholderConfigurer", placeholderConfigurer);
ctx.refresh();
@@ -536,6 +537,7 @@ public class ConfigurationClassProcessingTests {
String nameSuffix = "-processed-" + myProp;
@SuppressWarnings("unused")
public void setNameSuffix(String nameSuffix) {
this.nameSuffix = nameSuffix;
}
@@ -552,10 +554,6 @@ public class ConfigurationClassProcessingTests {
public Object postProcessAfterInitialization(Object bean, String beanName) {
return bean;
}
public int getOrder() {
return 0;
}
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 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,6 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
@@ -166,8 +165,10 @@ public class ImportResourceTests {
}
}
@SuppressWarnings("deprecation")
@Configuration
@ImportResource(locations = "classpath:org/springframework/context/annotation/configuration/ImportNonXmlResourceConfig-context.properties", reader = PropertiesBeanDefinitionReader.class)
@ImportResource(locations = "classpath:org/springframework/context/annotation/configuration/ImportNonXmlResourceConfig-context.properties",
reader = org.springframework.beans.factory.support.PropertiesBeanDefinitionReader.class)
static class ImportNonXmlResourceConfig {
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2021 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.
@@ -59,6 +59,7 @@ public class ImportWithConditionTests {
protected static class ConditionalThenUnconditional {
@Autowired
@SuppressWarnings("unused")
private BeanOne beanOne;
}
@@ -68,6 +69,7 @@ public class ImportWithConditionTests {
protected static class UnconditionalThenConditional {
@Autowired
@SuppressWarnings("unused")
private BeanOne beanOne;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 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.
@@ -47,6 +47,7 @@ public class ImportedConfigurationClassEnhancementTests {
autowiredConfigClassIsEnhanced(ConfigThatDoesNotImport.class, ConfigToBeAutowired.class);
}
@SuppressWarnings("deprecation")
private void autowiredConfigClassIsEnhanced(Class<?>... configClasses) {
ApplicationContext ctx = new AnnotationConfigApplicationContext(configClasses);
Config config = ctx.getBean(Config.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 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.
@@ -32,6 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class Spr7167Tests {
@SuppressWarnings("deprecation")
@Test
public void test() {
ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(MyConfig.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 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.
@@ -22,7 +22,6 @@ import org.springframework.beans.BeansException;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
@@ -75,6 +74,7 @@ public class BeanFactoryPostProcessorTests {
}
@Test
@SuppressWarnings("deprecation")
public void testMultipleDefinedBeanFactoryPostProcessors() {
StaticApplicationContext ac = new StaticApplicationContext();
ac.registerSingleton("tb1", TestBean.class);
@@ -84,7 +84,7 @@ public class BeanFactoryPostProcessorTests {
ac.registerSingleton("bfpp1", TestBeanFactoryPostProcessor.class, pvs1);
MutablePropertyValues pvs2 = new MutablePropertyValues();
pvs2.add("properties", "key=value");
ac.registerSingleton("bfpp2", PropertyPlaceholderConfigurer.class, pvs2);
ac.registerSingleton("bfpp2", org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.class, pvs2);
ac.refresh();
TestBeanFactoryPostProcessor bfpp = (TestBeanFactoryPostProcessor) ac.getBean("bfpp1");
assertThat(bfpp.initValue).isEqualTo("value");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 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.
@@ -38,6 +38,7 @@ import static org.mockito.Mockito.mock;
* @author Stephane Nicoll
* @author Sam Brannen
*/
@SuppressWarnings("deprecation")
class LiveBeansViewTests {
private final MockEnvironment environment = new MockEnvironment();

View File

@@ -43,6 +43,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Sam Brannen
* @see org.springframework.beans.factory.config.PropertyResourceConfigurerTests
*/
@SuppressWarnings("deprecation")
public class PropertyResourceConfigurerIntegrationTests {
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 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.
@@ -46,7 +46,6 @@ import static org.springframework.beans.factory.support.BeanDefinitionBuilder.ro
*/
public class PropertySourcesPlaceholderConfigurerTests {
@Test
public void replacementFromEnvironmentProperties() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
@@ -397,6 +396,7 @@ public class PropertySourcesPlaceholderConfigurerTests {
return name;
}
@SuppressWarnings("unused")
public void setName(Optional<String> name) {
this.name = name;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 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.
@@ -23,7 +23,6 @@ import java.util.Map;
import org.junit.jupiter.api.Test;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ConfigurableApplicationContext;
@@ -48,6 +47,7 @@ public class StaticApplicationContextMulticasterTests extends AbstractApplicatio
protected StaticApplicationContext sac;
@SuppressWarnings("deprecation")
@Override
protected ConfigurableApplicationContext createContext() throws Exception {
StaticApplicationContext parent = new StaticApplicationContext();
@@ -67,7 +67,8 @@ public class StaticApplicationContextMulticasterTests extends AbstractApplicatio
sac.registerSingleton("beanThatListens", BeanThatListens.class, new MutablePropertyValues());
sac.registerSingleton("aca", ACATester.class, new MutablePropertyValues());
sac.registerPrototype("aca-prototype", ACATester.class, new MutablePropertyValues());
PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(sac.getDefaultListableBeanFactory());
org.springframework.beans.factory.support.PropertiesBeanDefinitionReader reader =
new org.springframework.beans.factory.support.PropertiesBeanDefinitionReader(sac.getDefaultListableBeanFactory());
Resource resource = new ClassPathResource("testBeans.properties", getClass());
reader.loadBeanDefinitions(new EncodedResource(resource, "ISO-8859-1"));
sac.refresh();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2021 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.
@@ -23,7 +23,6 @@ import java.util.Map;
import org.junit.jupiter.api.Test;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.testfixture.AbstractApplicationContextTests;
@@ -40,6 +39,7 @@ public class StaticApplicationContextTests extends AbstractApplicationContextTes
protected StaticApplicationContext sac;
@SuppressWarnings("deprecation")
@Override
protected ConfigurableApplicationContext createContext() throws Exception {
StaticApplicationContext parent = new StaticApplicationContext();
@@ -57,7 +57,8 @@ public class StaticApplicationContextTests extends AbstractApplicationContextTes
sac.registerSingleton("beanThatListens", BeanThatListens.class, new MutablePropertyValues());
sac.registerSingleton("aca", ACATester.class, new MutablePropertyValues());
sac.registerPrototype("aca-prototype", ACATester.class, new MutablePropertyValues());
PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(sac.getDefaultListableBeanFactory());
org.springframework.beans.factory.support.PropertiesBeanDefinitionReader reader =
new org.springframework.beans.factory.support.PropertiesBeanDefinitionReader(sac.getDefaultListableBeanFactory());
reader.loadBeanDefinitions(new ClassPathResource("testBeans.properties", getClass()));
sac.refresh();
sac.addApplicationListener(listener);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 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,6 @@ import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.MessageSourceResolvable;
import org.springframework.context.NoSuchMessageException;
@@ -176,6 +175,7 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests {
sac.getMessage(resolvable4, Locale.US));
}
@SuppressWarnings("deprecation")
@Override
protected ConfigurableApplicationContext createContext() throws Exception {
StaticApplicationContext parent = new StaticApplicationContext();
@@ -197,7 +197,8 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests {
sac.registerPrototype("aca-prototype", ACATester.class, new MutablePropertyValues());
PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(sac.getDefaultListableBeanFactory());
org.springframework.beans.factory.support.PropertiesBeanDefinitionReader reader =
new org.springframework.beans.factory.support.PropertiesBeanDefinitionReader(sac.getDefaultListableBeanFactory());
reader.loadBeanDefinitions(new ClassPathResource("testBeans.properties", getClass()));
sac.refresh();
sac.addApplicationListener(listener);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 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.
@@ -251,7 +251,7 @@ public class EnableMBeanExportConfigurationTests {
@Bean
@Lazy
public Object notLoadable() throws Exception {
return Class.forName("does.not.exist").newInstance();
return Class.forName("does.not.exist").getDeclaredConstructor().newInstance();
}
}