Skip to content

Commit b2bdc7d

Browse files
committed
Polishing
1 parent 8f2bb49 commit b2bdc7d

File tree

24 files changed

+125
-157
lines changed

24 files changed

+125
-157
lines changed

Diff for: spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@
9797
* Supports autowiring constructors, properties by name, and properties by type.
9898
*
9999
* <p>The main template method to be implemented by subclasses is
100-
* {@link #resolveDependency(DependencyDescriptor, String, Set, TypeConverter)},
101-
* used for autowiring by type. In case of a factory which is capable of searching
102-
* its bean definitions, matching beans will typically be implemented through such
103-
* a search. For other factory styles, simplified matching algorithms can be implemented.
100+
* {@link #resolveDependency(DependencyDescriptor, String, Set, TypeConverter)}, used for
101+
* autowiring. In case of a {@link org.springframework.beans.factory.ListableBeanFactory}
102+
* which is capable of searching its bean definitions, matching beans will typically be
103+
* implemented through such a search. Otherwise, simplified matching can be implemented.
104104
*
105105
* <p>Note that this class does <i>not</i> assume or implement bean definition
106106
* registry capabilities. See {@link DefaultListableBeanFactory} for an implementation
@@ -675,7 +675,7 @@ protected Class<?> predictBeanType(String beanName, RootBeanDefinition mbd, Clas
675675
// Apply SmartInstantiationAwareBeanPostProcessors to predict the
676676
// eventual type after a before-instantiation shortcut.
677677
if (targetType != null && !mbd.isSynthetic() && hasInstantiationAwareBeanPostProcessors()) {
678-
boolean matchingOnlyFactoryBean = typesToMatch.length == 1 && typesToMatch[0] == FactoryBean.class;
678+
boolean matchingOnlyFactoryBean = (typesToMatch.length == 1 && typesToMatch[0] == FactoryBean.class);
679679
for (SmartInstantiationAwareBeanPostProcessor bp : getBeanPostProcessorCache().smartInstantiationAware) {
680680
Class<?> predicted = bp.predictBeanType(targetType, beanName);
681681
if (predicted != null &&

Diff for: spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java

+2-2
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.
@@ -749,7 +749,7 @@ public String[] getAliases(String name) {
749749
aliases.add(fullBeanName);
750750
}
751751
String[] retrievedAliases = super.getAliases(beanName);
752-
String prefix = factoryPrefix ? FACTORY_BEAN_PREFIX : "";
752+
String prefix = (factoryPrefix ? FACTORY_BEAN_PREFIX : "");
753753
for (String retrievedAlias : retrievedAliases) {
754754
String alias = prefix + retrievedAlias;
755755
if (!alias.equals(name)) {

Diff for: spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,7 @@ public ConstructorResolver(AbstractAutowireCapableBeanFactory beanFactory) {
107107

108108
/**
109109
* "autowire constructor" (with constructor arguments by type) behavior.
110-
* Also applied if explicit constructor argument values are specified,
111-
* matching all remaining arguments with beans from the bean factory.
112-
* <p>This corresponds to constructor injection: In this mode, a Spring
113-
* bean factory is able to host components that expect constructor-based
114-
* dependency resolution.
110+
* Also applied if explicit constructor argument values are specified.
115111
* @param beanName the name of the bean
116112
* @param mbd the merged bean definition for the bean
117113
* @param chosenCtors chosen candidate constructors (or {@code null} if none)

Diff for: spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ protected Cache adaptCaffeineCache(String name, com.github.benmanes.caffeine.cac
236236
* Build a common {@link CaffeineCache} instance for the specified cache name,
237237
* using the common Caffeine configuration specified on this cache manager.
238238
* <p>Delegates to {@link #adaptCaffeineCache} as the adaptation method to
239-
* Spring's cache abstraction (allowing for centralized decoration etc),
239+
* Spring's cache abstraction (allowing for centralized decoration etc.),
240240
* passing in a freshly built native Caffeine Cache instance.
241241
* @param name the name of the cache
242242
* @return the Spring CaffeineCache adapter (or a decorator thereof)

Diff for: spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -547,10 +547,10 @@ private Cache.ValueWrapper findCachedItem(Collection<CacheOperationContext> cont
547547
}
548548

549549
/**
550-
* Collect the {@link CachePutRequest} for all {@link CacheOperation} using
551-
* the specified result value.
550+
* Collect a {@link CachePutRequest} for every {@link CacheOperation}
551+
* using the specified result value.
552552
* @param contexts the contexts to handle
553-
* @param result the result value (never {@code null})
553+
* @param result the result value
554554
* @param putRequests the collection to update
555555
*/
556556
private void collectPutRequests(Collection<CacheOperationContext> contexts,

Diff for: spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperationInvoker.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 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.
@@ -22,7 +22,7 @@
2222
* Abstract the invocation of a cache operation.
2323
*
2424
* <p>Does not provide a way to transmit checked exceptions but
25-
* provide a special exception that should be used to wrap any
25+
* provides a special exception that should be used to wrap any
2626
* exception that was thrown by the underlying invocation.
2727
* Callers are expected to handle this issue type specifically.
2828
*

Diff for: spring-context/src/main/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.java

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 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.
@@ -62,11 +62,13 @@
6262
import org.springframework.util.ClassUtils;
6363

6464
/**
65-
* A component provider that provides candidate components from a base package. Can
66-
* use {@link CandidateComponentsIndex the index} if it is available of scans the
67-
* classpath otherwise. Candidate components are identified by applying exclude and
68-
* include filters. {@link AnnotationTypeFilter}, {@link AssignableTypeFilter} include
69-
* filters on an annotation/superclass that are annotated with {@link Indexed} are
65+
* A component provider that scans for candidate components starting from a
66+
* specified base package. Can use the {@linkplain CandidateComponentsIndex component
67+
* index}, if it is available, and scans the classpath otherwise.
68+
*
69+
* <p>Candidate components are identified by applying exclude and include filters.
70+
* {@link AnnotationTypeFilter} and {@link AssignableTypeFilter} include filters
71+
* for an annotation/target-type that is annotated with {@link Indexed} are
7072
* supported: if any other include filter is specified, the index is ignored and
7173
* classpath scanning is used instead.
7274
*
@@ -304,7 +306,7 @@ public final MetadataReaderFactory getMetadataReaderFactory() {
304306

305307

306308
/**
307-
* Scan the class path for candidate components.
309+
* Scan the component index or class path for candidate components.
308310
* @param basePackage the package to check for annotated classes
309311
* @return a corresponding Set of autodetected bean definitions
310312
*/
@@ -318,7 +320,7 @@ public Set<BeanDefinition> findCandidateComponents(String basePackage) {
318320
}
319321

320322
/**
321-
* Determine if the index can be used by this instance.
323+
* Determine if the component index can be used by this instance.
322324
* @return {@code true} if the index is available and the configuration of this
323325
* instance is supported by it, {@code false} otherwise
324326
* @since 5.0
@@ -454,8 +456,7 @@ private Set<BeanDefinition> scanCandidateComponents(String basePackage) {
454456
}
455457
}
456458
catch (Throwable ex) {
457-
throw new BeanDefinitionStoreException(
458-
"Failed to read candidate component class: " + resource, ex);
459+
throw new BeanDefinitionStoreException("Failed to read candidate component class: " + resource, ex);
459460
}
460461
}
461462
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
211211
/** Flag that indicates whether this context has been closed already. */
212212
private final AtomicBoolean closed = new AtomicBoolean();
213213

214-
/** Synchronization monitor for the "refresh" and "destroy". */
214+
/** Synchronization monitor for "refresh" and "close". */
215215
private final Object startupShutdownMonitor = new Object();
216216

217217
/** Reference to the JVM shutdown hook, if registered. */

Diff for: spring-context/src/main/java/org/springframework/scheduling/TaskScheduler.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 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.
@@ -29,7 +29,7 @@
2929
* {@link Runnable Runnables} based on different kinds of triggers.
3030
*
3131
* <p>This interface is separate from {@link SchedulingTaskExecutor} since it
32-
* usually represents for a different kind of backend, i.e. a thread pool with
32+
* usually represents a different kind of backend, i.e. a thread pool with
3333
* different characteristics and capabilities. Implementations may implement
3434
* both interfaces if they can handle both kinds of execution characteristics.
3535
*

Diff for: spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 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.
@@ -138,8 +138,8 @@ void withCustomFactoryAsMeta() {
138138
@Test
139139
void withUnresolvablePlaceholder() {
140140
assertThatExceptionOfType(BeanDefinitionStoreException.class)
141-
.isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithUnresolvablePlaceholder.class))
142-
.withCauseInstanceOf(IllegalArgumentException.class);
141+
.isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithUnresolvablePlaceholder.class))
142+
.withCauseInstanceOf(IllegalArgumentException.class);
143143
}
144144

145145
@Test
@@ -170,8 +170,8 @@ void withResolvablePlaceholderAndFactoryBean() {
170170
@Test
171171
void withEmptyResourceLocations() {
172172
assertThatExceptionOfType(BeanDefinitionStoreException.class)
173-
.isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithEmptyResourceLocations.class))
174-
.withCauseInstanceOf(IllegalArgumentException.class);
173+
.isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithEmptyResourceLocations.class))
174+
.withCauseInstanceOf(IllegalArgumentException.class);
175175
}
176176

177177
@Test
@@ -253,8 +253,8 @@ void withNamedPropertySources() {
253253
@Test
254254
void withMissingPropertySource() {
255255
assertThatExceptionOfType(BeanDefinitionStoreException.class)
256-
.isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithMissingPropertySource.class))
257-
.withCauseInstanceOf(FileNotFoundException.class);
256+
.isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithMissingPropertySource.class))
257+
.withCauseInstanceOf(FileNotFoundException.class);
258258
}
259259

260260
@Test

Diff for: spring-context/src/test/java/org/springframework/context/support/GenericApplicationContextTests.java

+5-5
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.
@@ -102,16 +102,16 @@ void accessAfterClosing() {
102102

103103
assertThat(context.getBean(String.class)).isSameAs(context.getBean("testBean"));
104104
assertThat(context.getAutowireCapableBeanFactory().getBean(String.class))
105-
.isSameAs(context.getAutowireCapableBeanFactory().getBean("testBean"));
105+
.isSameAs(context.getAutowireCapableBeanFactory().getBean("testBean"));
106106

107107
context.close();
108108

109109
assertThatIllegalStateException()
110-
.isThrownBy(() -> context.getBean(String.class));
110+
.isThrownBy(() -> context.getBean(String.class));
111111
assertThatIllegalStateException()
112-
.isThrownBy(() -> context.getAutowireCapableBeanFactory().getBean(String.class));
112+
.isThrownBy(() -> context.getAutowireCapableBeanFactory().getBean(String.class));
113113
assertThatIllegalStateException()
114-
.isThrownBy(() -> context.getAutowireCapableBeanFactory().getBean("testBean"));
114+
.isThrownBy(() -> context.getAutowireCapableBeanFactory().getBean("testBean"));
115115
}
116116

117117
@Test

Diff for: spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-delegationOverrides.xml

+12-21
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
55

6-
<!--
7-
Not yet in use: illustration of possible approach
8-
-->
96
<bean id="overrideOneMethod" class="org.springframework.beans.factory.xml.OverrideOneMethod">
107

118
<lookup-method name="getPrototypeDependency" bean="jenny"/>
@@ -27,39 +24,34 @@
2724

2825
<lookup-method name="protectedOverrideSingleton" bean="david"/>
2926

30-
<!--
31-
This method is not overloaded, so we don't need to specify any arg types
32-
-->
27+
<!-- This method is not overloaded, so we don't need to specify any arg types -->
3328
<replaced-method name="doSomething" replacer="doSomethingReplacer"/>
3429

3530
</bean>
3631

37-
<bean id="replaceVoidMethod" parent="someParent"
38-
class="org.springframework.beans.factory.xml.OverrideOneMethodSubclass">
32+
<bean id="replaceVoidMethod" parent="someParent" class="org.springframework.beans.factory.xml.OverrideOneMethodSubclass"/>
3933

34+
<bean id="replaceEchoMethod" class="org.springframework.beans.factory.xml.EchoService">
35+
<!-- This method is not overloaded, so we don't need to specify any arg types -->
36+
<replaced-method name="echo" replacer="reverseArrayReplacer" />
4037
</bean>
4138

42-
<bean id="reverseReplacer"
43-
class="org.springframework.beans.factory.xml.ReverseMethodReplacer"/>
39+
<bean id="reverseReplacer" class="org.springframework.beans.factory.xml.ReverseMethodReplacer"/>
4440

45-
<bean id="fixedReplacer"
46-
class="org.springframework.beans.factory.xml.FixedMethodReplacer"/>
41+
<bean id="reverseArrayReplacer" class="org.springframework.beans.factory.xml.ReverseArrayMethodReplacer"/>
4742

48-
<bean id="doSomethingReplacer"
49-
class="org.springframework.beans.factory.xml.XmlBeanFactoryTests$DoSomethingReplacer"/>
43+
<bean id="fixedReplacer" class="org.springframework.beans.factory.xml.FixedMethodReplacer"/>
5044

51-
<bean id="serializableReplacer"
52-
class="org.springframework.beans.factory.xml.SerializableMethodReplacerCandidate">
45+
<bean id="doSomethingReplacer" class="org.springframework.beans.factory.xml.XmlBeanFactoryTests$DoSomethingReplacer"/>
5346

47+
<bean id="serializableReplacer" class="org.springframework.beans.factory.xml.SerializableMethodReplacerCandidate">
5448
<!-- Arbitrary method replacer -->
5549
<replaced-method name="replaceMe" replacer="reverseReplacer">
5650
<arg-type>String</arg-type>
5751
</replaced-method>
58-
5952
</bean>
6053

61-
<bean id="jenny" class="org.springframework.beans.testfixture.beans.TestBean"
62-
scope="prototype">
54+
<bean id="jenny" class="org.springframework.beans.testfixture.beans.TestBean" scope="prototype">
6355
<property name="name"><value>Jenny</value></property>
6456
<property name="age"><value>30</value></property>
6557
<property name="spouse">
@@ -68,8 +60,7 @@
6860
</property>
6961
</bean>
7062

71-
<bean id="david" class="org.springframework.beans.testfixture.beans.TestBean"
72-
scope="singleton">
63+
<bean id="david" class="org.springframework.beans.testfixture.beans.TestBean" scope="singleton">
7364
<description>
7465
Simple bean, without any collections.
7566
</description>

Diff for: spring-core/src/main/java/org/springframework/core/SerializableTypeWrapper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ interface TypeProvider extends Serializable {
159159

160160
/**
161161
* Return the source of the type, or {@code null} if not known.
162-
* <p>The default implementations returns {@code null}.
162+
* <p>The default implementation returns {@code null}.
163163
*/
164164
@Nullable
165165
default Object getSource() {

0 commit comments

Comments
 (0)