Skip to content

Commit 4b8adf2

Browse files
committed
Polishing
1 parent c685525 commit 4b8adf2

27 files changed

+127
-141
lines changed

spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ public String[] getParameterNames(Constructor<?> ctor) {
302302
}
303303

304304

305-
private void bindParameterName(int index, String name) {
305+
private void bindParameterName(int index, @Nullable String name) {
306306
this.parameterNameBindings[index] = name;
307307
this.numberOfRemainingUnboundArguments--;
308308
}

spring-beans/src/main/java/org/springframework/beans/TypeConverterSupport.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-2023 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.
@@ -63,8 +63,8 @@ public <T> T convertIfNecessary(@Nullable Object value, @Nullable Class<T> requi
6363
(field != null ? new TypeDescriptor(field) : TypeDescriptor.valueOf(requiredType)));
6464
}
6565

66-
@Nullable
6766
@Override
67+
@Nullable
6868
public <T> T convertIfNecessary(@Nullable Object value, @Nullable Class<T> requiredType,
6969
@Nullable TypeDescriptor typeDescriptor) throws TypeMismatchException {
7070

spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
102102
private boolean singletonsCurrentlyInDestruction = false;
103103

104104
/** Disposable bean instances: bean name to disposable instance. */
105-
private final Map<String, Object> disposableBeans = new LinkedHashMap<>();
105+
private final Map<String, DisposableBean> disposableBeans = new LinkedHashMap<>();
106106

107107
/** Map between containing bean names: bean name to Set of bean names that the bean contains. */
108108
private final Map<String, Set<String>> containedBeanMap = new ConcurrentHashMap<>(16);
@@ -554,7 +554,7 @@ public void destroySingleton(String beanName) {
554554
// Destroy the corresponding DisposableBean instance.
555555
DisposableBean disposableBean;
556556
synchronized (this.disposableBeans) {
557-
disposableBean = (DisposableBean) this.disposableBeans.remove(beanName);
557+
disposableBean = this.disposableBeans.remove(beanName);
558558
}
559559
destroyBean(beanName, disposableBean);
560560
}

spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
6565

6666
private static final String SHUTDOWN_METHOD_NAME = "shutdown";
6767

68-
private static final Log logger = LogFactory.getLog(DisposableBeanAdapter.class);
6968

69+
private static final Log logger = LogFactory.getLog(DisposableBeanAdapter.class);
7070

7171
private final Object bean;
7272

@@ -240,7 +240,7 @@ else if (this.destroyMethods != null) {
240240
}
241241
}
242242
else if (this.destroyMethodNames != null) {
243-
for (String destroyMethodName: this.destroyMethodNames) {
243+
for (String destroyMethodName : this.destroyMethodNames) {
244244
Method destroyMethod = determineDestroyMethod(destroyMethodName);
245245
if (destroyMethod != null) {
246246
invokeCustomDestroyMethod(
@@ -288,7 +288,7 @@ private Method findDestroyMethod(Class<?> clazz, String name) {
288288
*/
289289
private void invokeCustomDestroyMethod(Method destroyMethod) {
290290
int paramCount = destroyMethod.getParameterCount();
291-
final Object[] args = new Object[paramCount];
291+
Object[] args = new Object[paramCount];
292292
if (paramCount == 1) {
293293
args[0] = Boolean.TRUE;
294294
}

spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ ApplicationEventMulticaster getApplicationEventMulticaster() throws IllegalState
463463

464464
@Override
465465
public void setApplicationStartup(ApplicationStartup applicationStartup) {
466-
Assert.notNull(applicationStartup, "applicationStartup must not be null");
466+
Assert.notNull(applicationStartup, "ApplicationStartup must not be null");
467467
this.applicationStartup = applicationStartup;
468468
}
469469

@@ -946,7 +946,6 @@ protected void finishBeanFactoryInitialization(ConfigurableListableBeanFactory b
946946
* onRefresh() method and publishing the
947947
* {@link org.springframework.context.event.ContextRefreshedEvent}.
948948
*/
949-
@SuppressWarnings("deprecation")
950949
protected void finishRefresh() {
951950
// Clear context-level resource caches (such as ASM metadata from scanning).
952951
clearResourceCaches();
@@ -1047,7 +1046,6 @@ public void close() {
10471046
* @see #close()
10481047
* @see #registerShutdownHook()
10491048
*/
1050-
@SuppressWarnings("deprecation")
10511049
protected void doClose() {
10521050
// Check whether an actual close attempt is necessary...
10531051
if (this.active.get() && this.closed.compareAndSet(false, true)) {

spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportTests.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 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.
@@ -41,6 +41,7 @@ class ImportTests {
4141

4242
private DefaultListableBeanFactory processConfigurationClasses(Class<?>... classes) {
4343
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
44+
beanFactory.setAllowBeanDefinitionOverriding(false);
4445
for (Class<?> clazz : classes) {
4546
beanFactory.registerBeanDefinition(clazz.getSimpleName(), new RootBeanDefinition(clazz));
4647
}
@@ -56,9 +57,10 @@ private void assertBeanDefinitionCount(int expectedCount, Class<?>... classes) {
5657
for (Class<?> clazz : classes) {
5758
beanFactory.getBean(clazz);
5859
}
59-
6060
}
6161

62+
// ------------------------------------------------------------------------
63+
6264
@Test
6365
void testProcessImportsWithAsm() {
6466
int configClasses = 2;
@@ -158,6 +160,13 @@ void testImportAnnotationWithThreeLevelRecursion() {
158160
assertBeanDefinitionCount(configClasses + beansInClasses, FirstLevel.class);
159161
}
160162

163+
@Test
164+
void testImportAnnotationWithThreeLevelRecursionAndDoubleImport() {
165+
int configClasses = 5;
166+
int beansInClasses = 5;
167+
assertBeanDefinitionCount(configClasses + beansInClasses, FirstLevel.class, FirstLevelPlus.class);
168+
}
169+
161170
// ------------------------------------------------------------------------
162171

163172
@Test
@@ -167,7 +176,6 @@ void testImportAnnotationWithMultipleArguments() {
167176
assertBeanDefinitionCount((configClasses + beansInClasses), WithMultipleArgumentsToImportAnnotation.class);
168177
}
169178

170-
171179
@Test
172180
void testImportAnnotationWithMultipleArgumentsResultingInOverriddenBeanDefinition() {
173181
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
@@ -245,6 +253,11 @@ TestBean m() {
245253
}
246254
}
247255

256+
@Configuration
257+
@Import(ThirdLevel.class)
258+
static class FirstLevelPlus {
259+
}
260+
248261
@Configuration
249262
@Import({ThirdLevel.class, InitBean.class})
250263
static class SecondLevel {

spring-core/src/main/java/org/springframework/core/MethodParameter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,7 @@ public MethodParameter clone() {
780780
return new MethodParameter(this);
781781
}
782782

783+
783784
/**
784785
* Create a new MethodParameter for the given method or constructor.
785786
* <p>This is a convenience factory method for scenarios where a

spring-r2dbc/src/test/java/org/springframework/r2dbc/connection/ConnectionFactoryUtilsUnitTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void shouldTranslateTimeoutException() {
7575
@Test
7676
public void shouldNotTranslateUnknownExceptions() {
7777
Exception exception = ConnectionFactoryUtils.convertR2dbcException("", "",
78-
new MyTransientExceptions());
78+
new MyTransientException());
7979
assertThat(exception).isExactlyInstanceOf(UncategorizedR2dbcException.class);
8080
}
8181

@@ -153,7 +153,7 @@ public void messageGenerationNullMessage() {
153153

154154

155155
@SuppressWarnings("serial")
156-
private static class MyTransientExceptions extends R2dbcException {
156+
private static class MyTransientException extends R2dbcException {
157157
}
158158

159159
}

spring-r2dbc/src/test/java/org/springframework/r2dbc/connection/DelegatingConnectionFactoryUnitTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class DelegatingConnectionFactoryUnitTests {
4040

4141

4242
@Test
43-
@SuppressWarnings({ "rawtypes", "unchecked" })
43+
@SuppressWarnings({"rawtypes", "unchecked"})
4444
void shouldDelegateGetConnection() {
4545
Mono<Connection> connectionMono = Mono.just(connectionMock);
4646
when(delegate.create()).thenReturn((Mono) connectionMono);
@@ -53,6 +53,7 @@ void shouldDelegateUnwrapWithoutImplementing() {
5353
assertThat(connectionFactory.unwrap()).isSameAs(delegate);
5454
}
5555

56+
5657
static class ExampleConnectionFactory extends DelegatingConnectionFactory {
5758

5859
ExampleConnectionFactory(ConnectionFactory targetConnectionFactory) {

spring-r2dbc/src/test/java/org/springframework/r2dbc/connection/R2dbcTransactionManagerUnitTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class R2dbcTransactionManagerUnitTests {
6565

6666
private R2dbcTransactionManager tm;
6767

68+
6869
@BeforeEach
6970
@SuppressWarnings({ "unchecked", "rawtypes" })
7071
void before() {
@@ -74,6 +75,7 @@ void before() {
7475
tm = new R2dbcTransactionManager(connectionFactoryMock);
7576
}
7677

78+
7779
@Test
7880
void testSimpleTransaction() {
7981
TestTransactionSynchronization sync = new TestTransactionSynchronization(
@@ -445,8 +447,7 @@ void testPropagationSupportsAndRequiresNew() {
445447
}
446448

447449

448-
private static class TestTransactionSynchronization
449-
implements TransactionSynchronization {
450+
private static class TestTransactionSynchronization implements TransactionSynchronization {
450451

451452
private int status;
452453

@@ -519,7 +520,6 @@ protected void doAfterCompletion(int status) {
519520
this.afterCompletionCalled = true;
520521
assertThat(status).isEqualTo(this.status);
521522
}
522-
523523
}
524524

525525
}

spring-r2dbc/src/test/java/org/springframework/r2dbc/connection/SingleConnectionFactoryUnitTests.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ void shouldAllocateSameConnection() {
4848

4949
Connection c1 = cf1.block();
5050
Connection c2 = cf2.block();
51-
5251
assertThat(c1).isSameAs(c2);
52+
5353
factory.destroy();
5454
}
5555

@@ -63,7 +63,6 @@ void shouldApplyAutoCommit() {
6363
.verifyComplete();
6464

6565
factory.setAutoCommit(true);
66-
6766
factory.create().as(StepVerifier::create)
6867
.consumeNextWith(actual -> assertThat(actual.isAutoCommit()).isTrue())
6968
.verifyComplete();
@@ -75,7 +74,6 @@ void shouldApplyAutoCommit() {
7574
@SuppressWarnings("rawtypes")
7675
void shouldSuppressClose() {
7776
SingleConnectionFactory factory = new SingleConnectionFactory("r2dbc:h2:mem:///foo", true);
78-
7977
Connection connection = factory.create().block();
8078

8179
StepVerifier.create(connection.close()).verifyComplete();
@@ -85,19 +83,19 @@ void shouldSuppressClose() {
8583
StepVerifier.create(
8684
connection.setTransactionIsolationLevel(IsolationLevel.READ_COMMITTED))
8785
.verifyComplete();
86+
8887
factory.destroy();
8988
}
9089

9190
@Test
9291
void shouldNotSuppressClose() {
9392
SingleConnectionFactory factory = new SingleConnectionFactory("r2dbc:h2:mem:///foo", false);
94-
9593
Connection connection = factory.create().block();
9694

9795
StepVerifier.create(connection.close()).verifyComplete();
98-
9996
StepVerifier.create(connection.setTransactionIsolationLevel(IsolationLevel.READ_COMMITTED))
10097
.verifyError(R2dbcNonTransientResourceException.class);
98+
10199
factory.destroy();
102100
}
103101

@@ -107,7 +105,6 @@ void releaseConnectionShouldNotCloseConnection() {
107105
ConnectionFactoryMetadata metadata = mock();
108106

109107
SingleConnectionFactory factory = new SingleConnectionFactory(connectionMock, metadata, true);
110-
111108
Connection connection = factory.create().block();
112109

113110
ConnectionFactoryUtils.releaseConnection(connection, factory)
@@ -125,7 +122,6 @@ void releaseConnectionShouldCloseUnrelatedConnection() {
125122
when(otherConnection.close()).thenReturn(Mono.empty());
126123

127124
SingleConnectionFactory factory = new SingleConnectionFactory(connectionMock, metadata, false);
128-
129125
factory.create().as(StepVerifier::create).expectNextCount(1).verifyComplete();
130126

131127
ConnectionFactoryUtils.releaseConnection(otherConnection, factory)

spring-r2dbc/src/test/java/org/springframework/r2dbc/connection/TransactionAwareConnectionFactoryProxyUnitTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class TransactionAwareConnectionFactoryProxyUnitTests {
5555

5656
R2dbcTransactionManager tm;
5757

58+
5859
@BeforeEach
5960
@SuppressWarnings({ "rawtypes", "unchecked" })
6061
void before() {
@@ -63,6 +64,7 @@ void before() {
6364
tm = new R2dbcTransactionManager(connectionFactoryMock);
6465
}
6566

67+
6668
@Test
6769
void createShouldWrapConnection() {
6870
new TransactionAwareConnectionFactoryProxy(connectionFactoryMock).create()

0 commit comments

Comments
 (0)