Skip to content

Commit 9d5881e

Browse files
committed
Suppress warnings, remove unused code, etc.
1 parent 2f0970b commit 9d5881e

File tree

53 files changed

+418
-449
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+418
-449
lines changed

spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@
7474
import org.springframework.beans.factory.support.ChildBeanDefinition;
7575
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
7676
import org.springframework.beans.factory.support.ManagedList;
77-
import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader;
7877
import org.springframework.beans.factory.support.RootBeanDefinition;
7978
import org.springframework.beans.factory.xml.ConstructorDependenciesBean;
8079
import org.springframework.beans.propertyeditors.CustomNumberEditor;
@@ -139,7 +138,7 @@ void unreferencedSingletonWasInstantiated() {
139138
Properties p = new Properties();
140139
p.setProperty("x1.(class)", KnowsIfInstantiated.class.getName());
141140
assertThat(!KnowsIfInstantiated.wasInstantiated()).as("singleton not instantiated").isTrue();
142-
(new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
141+
registerBeanDefinitions(p);
143142
lbf.preInstantiateSingletons();
144143
assertThat(KnowsIfInstantiated.wasInstantiated()).as("singleton was instantiated").isTrue();
145144
}
@@ -151,7 +150,7 @@ void lazyInitialization() {
151150
p.setProperty("x1.(class)", KnowsIfInstantiated.class.getName());
152151
p.setProperty("x1.(lazy-init)", "true");
153152
assertThat(!KnowsIfInstantiated.wasInstantiated()).as("singleton not instantiated").isTrue();
154-
(new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
153+
registerBeanDefinitions(p);
155154
assertThat(!KnowsIfInstantiated.wasInstantiated()).as("singleton not instantiated").isTrue();
156155
lbf.preInstantiateSingletons();
157156

@@ -168,7 +167,7 @@ void factoryBeanDidNotCreatePrototype() {
168167
DummyFactory.reset();
169168
p.setProperty("x1.singleton", "false");
170169
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
171-
(new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
170+
registerBeanDefinitions(p);
172171
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
173172
assertThat(lbf.getType("x1")).isEqualTo(TestBean.class);
174173
lbf.preInstantiateSingletons();
@@ -189,7 +188,7 @@ void prototypeFactoryBeanIgnoredByNonEagerTypeMatching() {
189188
DummyFactory.reset();
190189
p.setProperty("x1.(singleton)", "false");
191190
p.setProperty("x1.singleton", "false");
192-
(new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
191+
registerBeanDefinitions(p);
193192

194193
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
195194
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
@@ -223,7 +222,7 @@ void singletonFactoryBeanIgnoredByNonEagerTypeMatching() {
223222
DummyFactory.reset();
224223
p.setProperty("x1.(singleton)", "false");
225224
p.setProperty("x1.singleton", "true");
226-
(new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
225+
registerBeanDefinitions(p);
227226

228227
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
229228
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
@@ -256,7 +255,7 @@ void nonInitializedFactoryBeanIgnoredByNonEagerTypeMatching() {
256255
// Reset static state
257256
DummyFactory.reset();
258257
p.setProperty("x1.singleton", "false");
259-
(new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
258+
registerBeanDefinitions(p);
260259

261260
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
262261
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
@@ -289,7 +288,7 @@ void initializedFactoryBeanFoundByNonEagerTypeMatching() {
289288
// Reset static state
290289
DummyFactory.reset();
291290
p.setProperty("x1.singleton", "false");
292-
(new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
291+
registerBeanDefinitions(p);
293292
lbf.preInstantiateSingletons();
294293

295294
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
@@ -483,7 +482,7 @@ void empty() {
483482
@Test
484483
void emptyPropertiesPopulation() {
485484
Properties p = new Properties();
486-
(new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
485+
registerBeanDefinitions(p);
487486
assertThat(lbf.getBeanDefinitionCount() == 0).as("No beans defined after ignorable invalid").isTrue();
488487
}
489488

@@ -492,7 +491,7 @@ void harmlessIgnorableRubbish() {
492491
Properties p = new Properties();
493492
p.setProperty("foo", "bar");
494493
p.setProperty("qwert", "er");
495-
(new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p, "test");
494+
registerBeanDefinitions(p, "test");
496495
assertThat(lbf.getBeanDefinitionCount() == 0).as("No beans defined after harmless ignorable rubbish").isTrue();
497496
}
498497

@@ -502,7 +501,7 @@ void propertiesPopulationWithNullPrefix() {
502501
p.setProperty("test.(class)", TestBean.class.getName());
503502
p.setProperty("test.name", "Tony");
504503
p.setProperty("test.age", "48");
505-
int count = (new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
504+
int count = registerBeanDefinitions(p);
506505
assertThat(count == 1).as("1 beans registered, not " + count).isTrue();
507506
singleTestBean(lbf);
508507
}
@@ -514,7 +513,7 @@ void propertiesPopulationWithPrefix() {
514513
p.setProperty(PREFIX + "test.(class)", TestBean.class.getName());
515514
p.setProperty(PREFIX + "test.name", "Tony");
516515
p.setProperty(PREFIX + "test.age", "0x30");
517-
int count = (new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p, PREFIX);
516+
int count = registerBeanDefinitions(p, PREFIX);
518517
assertThat(count == 1).as("1 beans registered, not " + count).isTrue();
519518
singleTestBean(lbf);
520519
}
@@ -532,7 +531,7 @@ void simpleReference() {
532531
p.setProperty(PREFIX + "kerry.age", "35");
533532
p.setProperty(PREFIX + "kerry.spouse(ref)", "rod");
534533

535-
int count = (new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p, PREFIX);
534+
int count = registerBeanDefinitions(p, PREFIX);
536535
assertThat(count == 2).as("2 beans registered, not " + count).isTrue();
537536

538537
TestBean kerry = lbf.getBean("kerry", TestBean.class);
@@ -549,7 +548,7 @@ void propertiesWithDotsInKey() {
549548
p.setProperty("tb.(class)", TestBean.class.getName());
550549
p.setProperty("tb.someMap[my.key]", "my.value");
551550

552-
int count = (new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
551+
int count = registerBeanDefinitions(p);
553552
assertThat(count == 1).as("1 beans registered, not " + count).isTrue();
554553
assertThat(lbf.getBeanDefinitionCount()).isEqualTo(1);
555554

@@ -567,7 +566,7 @@ void unresolvedReference() {
567566
p.setProperty(PREFIX + "kerry.age", "35");
568567
p.setProperty(PREFIX + "kerry.spouse(ref)", "rod");
569568

570-
new PropertiesBeanDefinitionReader(lbf).registerBeanDefinitions(p, PREFIX);
569+
registerBeanDefinitions(p, PREFIX);
571570
assertThatExceptionOfType(BeansException.class).as("unresolved reference").isThrownBy(() ->
572571
lbf.getBean("kerry"));
573572
}
@@ -690,7 +689,7 @@ void prototype() {
690689
Properties p = new Properties();
691690
p.setProperty("kerry.(class)", TestBean.class.getName());
692691
p.setProperty("kerry.age", "35");
693-
(new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
692+
registerBeanDefinitions(p);
694693
TestBean kerry1 = (TestBean) lbf.getBean("kerry");
695694
TestBean kerry2 = (TestBean) lbf.getBean("kerry");
696695
assertThat(kerry1 != null).as("Non null").isTrue();
@@ -701,7 +700,7 @@ void prototype() {
701700
p.setProperty("kerry.(class)", TestBean.class.getName());
702701
p.setProperty("kerry.(scope)", "prototype");
703702
p.setProperty("kerry.age", "35");
704-
(new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
703+
registerBeanDefinitions(p);
705704
kerry1 = (TestBean) lbf.getBean("kerry");
706705
kerry2 = (TestBean) lbf.getBean("kerry");
707706
assertThat(kerry1 != null).as("Non null").isTrue();
@@ -712,7 +711,7 @@ void prototype() {
712711
p.setProperty("kerry.(class)", TestBean.class.getName());
713712
p.setProperty("kerry.(scope)", "singleton");
714713
p.setProperty("kerry.age", "35");
715-
(new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
714+
registerBeanDefinitions(p);
716715
kerry1 = (TestBean) lbf.getBean("kerry");
717716
kerry2 = (TestBean) lbf.getBean("kerry");
718717
assertThat(kerry1 != null).as("Non null").isTrue();
@@ -731,7 +730,7 @@ void prototypeCircleLeadsToException() {
731730
p.setProperty("rod.age", "34");
732731
p.setProperty("rod.spouse", "*kerry");
733732

734-
new PropertiesBeanDefinitionReader(lbf).registerBeanDefinitions(p);
733+
registerBeanDefinitions(p);
735734
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
736735
lbf.getBean("kerry"))
737736
.satisfies(ex -> assertThat(ex.contains(BeanCurrentlyInCreationException.class)).isTrue());
@@ -745,7 +744,7 @@ void prototypeExtendsPrototype() {
745744

746745
p.setProperty("kerry.(parent)", "wife");
747746
p.setProperty("kerry.age", "35");
748-
(new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
747+
registerBeanDefinitions(p);
749748
TestBean kerry1 = (TestBean) lbf.getBean("kerry");
750749
TestBean kerry2 = (TestBean) lbf.getBean("kerry");
751750
assertThat(kerry1.getName()).isEqualTo("kerry");
@@ -760,7 +759,7 @@ void prototypeExtendsPrototype() {
760759
p.setProperty("kerry.(parent)", "wife");
761760
p.setProperty("kerry.(singleton)", "false");
762761
p.setProperty("kerry.age", "35");
763-
(new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
762+
registerBeanDefinitions(p);
764763
assertThat(lbf.isSingleton("kerry")).isFalse();
765764
kerry1 = (TestBean) lbf.getBean("kerry");
766765
kerry2 = (TestBean) lbf.getBean("kerry");
@@ -772,7 +771,7 @@ void prototypeExtendsPrototype() {
772771
p.setProperty("kerry.(class)", TestBean.class.getName());
773772
p.setProperty("kerry.(singleton)", "true");
774773
p.setProperty("kerry.age", "35");
775-
(new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
774+
registerBeanDefinitions(p);
776775
kerry1 = (TestBean) lbf.getBean("kerry");
777776
kerry2 = (TestBean) lbf.getBean("kerry");
778777
assertThat(kerry1 != null).as("Non null").isTrue();
@@ -823,9 +822,9 @@ void nameAlreadyBound() {
823822
Properties p = new Properties();
824823
p.setProperty("kerry.(class)", TestBean.class.getName());
825824
p.setProperty("kerry.age", "35");
826-
(new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
825+
registerBeanDefinitions(p);
827826
try {
828-
(new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
827+
registerBeanDefinitions(p);
829828
}
830829
catch (BeanDefinitionStoreException ex) {
831830
assertThat(ex.getBeanName()).isEqualTo("kerry");
@@ -965,7 +964,7 @@ void beanReferenceWithNewSyntax() {
965964
p.setProperty("k.(class)", TestBean.class.getName());
966965
p.setProperty("k.name", "kerry");
967966
p.setProperty("k.spouse", "*r");
968-
(new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
967+
registerBeanDefinitions(p);
969968
TestBean k = (TestBean) lbf.getBean("k");
970969
TestBean r = (TestBean) lbf.getBean("r");
971970
assertThat(k.getSpouse() == r).isTrue();
@@ -977,7 +976,7 @@ void canEscapeBeanReferenceSyntax() {
977976
Properties p = new Properties();
978977
p.setProperty("r.(class)", TestBean.class.getName());
979978
p.setProperty("r.name", "*" + name);
980-
(new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
979+
registerBeanDefinitions(p);
981980
TestBean r = (TestBean) lbf.getBean("r");
982981
assertThat(r.getName().equals(name)).isTrue();
983982
}
@@ -1081,7 +1080,7 @@ void registerExistingSingletonWithReference() {
10811080
p.setProperty("test.name", "Tony");
10821081
p.setProperty("test.age", "48");
10831082
p.setProperty("test.spouse(ref)", "singletonObject");
1084-
(new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
1083+
registerBeanDefinitions(p);
10851084
Object singletonObject = new TestBean();
10861085
lbf.registerSingleton("singletonObject", singletonObject);
10871086

@@ -1117,7 +1116,7 @@ void registerExistingSingletonWithNameOverriding() {
11171116
p.setProperty("test.name", "Tony");
11181117
p.setProperty("test.age", "48");
11191118
p.setProperty("test.spouse(ref)", "singletonObject");
1120-
(new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
1119+
registerBeanDefinitions(p);
11211120
lbf.registerBeanDefinition("singletonObject", new RootBeanDefinition(PropertiesFactoryBean.class));
11221121
Object singletonObject = new TestBean();
11231122
lbf.registerSingleton("singletonObject", singletonObject);
@@ -2895,6 +2894,16 @@ void registrationOfManySingletonsIsFastEnough() {
28952894
}
28962895
}
28972896

2897+
@SuppressWarnings("deprecation")
2898+
private int registerBeanDefinitions(Properties p) {
2899+
return (new org.springframework.beans.factory.support.PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
2900+
}
2901+
2902+
@SuppressWarnings("deprecation")
2903+
private int registerBeanDefinitions(Properties p, String prefix) {
2904+
return (new org.springframework.beans.factory.support.PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p, prefix);
2905+
}
2906+
28982907

28992908
static class A { }
29002909

spring-beans/src/test/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReaderTests.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,30 +26,31 @@
2626
/**
2727
* @author Rob Harrop
2828
*/
29-
public class PropertiesBeanDefinitionReaderTests {
29+
@SuppressWarnings("deprecation")
30+
class PropertiesBeanDefinitionReaderTests {
3031

3132
private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
3233

3334
private final PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(this.beanFactory);
3435

3536

3637
@Test
37-
public void withSimpleConstructorArg() {
38+
void withSimpleConstructorArg() {
3839
this.reader.loadBeanDefinitions(new ClassPathResource("simpleConstructorArg.properties", getClass()));
3940
TestBean bean = (TestBean) this.beanFactory.getBean("testBean");
4041
assertThat(bean.getName()).isEqualTo("Rob Harrop");
4142
}
4243

4344
@Test
44-
public void withConstructorArgRef() {
45+
void withConstructorArgRef() {
4546
this.reader.loadBeanDefinitions(new ClassPathResource("refConstructorArg.properties", getClass()));
4647
TestBean rob = (TestBean) this.beanFactory.getBean("rob");
4748
TestBean sally = (TestBean) this.beanFactory.getBean("sally");
4849
assertThat(rob.getSpouse()).isEqualTo(sally);
4950
}
5051

5152
@Test
52-
public void withMultipleConstructorsArgs() {
53+
void withMultipleConstructorsArgs() {
5354
this.reader.loadBeanDefinitions(new ClassPathResource("multiConstructorArgs.properties", getClass()));
5455
TestBean bean = (TestBean) this.beanFactory.getBean("testBean");
5556
assertThat(bean.getName()).isEqualTo("Rob Harrop");

spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,8 +25,6 @@
2525

2626
import static org.assertj.core.api.Assertions.assertThat;
2727

28-
29-
3028
/**
3129
* Tests for propagating enclosing beans element defaults to nested beans elements.
3230
*
@@ -69,7 +67,6 @@ private void assertLazyInits(DefaultListableBeanFactory bf) {
6967
}
7068

7169
@Test
72-
@SuppressWarnings("unchecked")
7370
public void defaultMerge() {
7471
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
7572
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
@@ -79,7 +76,6 @@ public void defaultMerge() {
7976
}
8077

8178
@Test
82-
@SuppressWarnings("unchecked")
8379
public void defaultMergeWithNonValidatingParser() {
8480
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
8581
XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(bf);

spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -175,12 +175,14 @@ public void testStringsWithPreparedStatementSetter() throws Exception {
175175
}
176176

177177
@Test
178+
@SuppressWarnings("deprecation")
178179
public void testStringsWithEmptyPreparedStatementArgs() throws Exception {
179180
doTestStrings(null, null, null, null,
180181
(template, sql, rch) -> template.query(sql, (Object[]) null, rch));
181182
}
182183

183184
@Test
185+
@SuppressWarnings("deprecation")
184186
public void testStringsWithPreparedStatementArgs() throws Exception {
185187
final Integer argument = 99;
186188
doTestStrings(null, null, null, argument,

spring-jdbc/src/test/java/org/springframework/jdbc/core/RowMapperTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -112,6 +112,7 @@ public void preparedStatementSetterWithRowMapper() throws SQLException {
112112
}
113113

114114
@Test
115+
@SuppressWarnings("deprecation")
115116
public void queryWithArgsAndRowMapper() throws SQLException {
116117
result = template.query("some SQL", new Object[] { "test1", "test2" }, testRowMapper);
117118
preparedStatement.setString(1, "test1");

spring-oxm/src/test/java/org/springframework/oxm/AbstractUnmarshallerTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -98,7 +98,7 @@ public void unmarshalStreamSourceInputStream() throws Exception {
9898
}
9999

100100
@Test
101-
@SuppressWarnings("deprecation")
101+
@SuppressWarnings("deprecation") // on JDK 9
102102
public void unmarshalSAXSource() throws Exception {
103103
XMLReader reader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
104104
SAXSource source = new SAXSource(reader, new InputSource(new StringReader(INPUT_STRING)));

0 commit comments

Comments
 (0)