Skip to content

Commit 912c270

Browse files
committed
Polishing
1 parent 4454ffd commit 912c270

File tree

6 files changed

+27
-24
lines changed

6 files changed

+27
-24
lines changed

spring-context/src/test/java/org/springframework/scheduling/concurrent/AbstractSchedulingTaskExecutorTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ public void submitCallableWithGetAfterShutdown() throws Exception {
165165
TestCallable task2 = new TestCallable(-1);
166166
Future<?> future2 = executor.submit(task2);
167167
shutdownExecutor();
168-
future1.get();
169-
future2.get();
168+
future1.get(100, TimeUnit.MILLISECONDS);
169+
future2.get(100, TimeUnit.MILLISECONDS);
170170
}
171171

172172
@Test
@@ -196,8 +196,8 @@ public void submitListenableCallableWithGetAfterShutdown() throws Exception {
196196
TestCallable task2 = new TestCallable(-1);
197197
ListenableFuture<?> future2 = executor.submitListenable(task2);
198198
shutdownExecutor();
199-
future1.get();
200-
future2.get();
199+
future1.get(100, TimeUnit.MILLISECONDS);
200+
future2.get(100, TimeUnit.MILLISECONDS);
201201
}
202202

203203

spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -592,18 +592,22 @@ private static <A extends Annotation> A searchOnInterfaces(Method method, Class<
592592
}
593593

594594
static Set<Method> getAnnotatedMethodsInBaseType(Class<?> baseType) {
595-
if (ClassUtils.isJavaLanguageInterface(baseType)) {
595+
boolean ifcCheck = baseType.isInterface();
596+
if (ifcCheck && ClassUtils.isJavaLanguageInterface(baseType)) {
596597
return Collections.emptySet();
597598
}
598599

599600
Set<Method> annotatedMethods = annotatedBaseTypeCache.get(baseType);
600601
if (annotatedMethods != null) {
601602
return annotatedMethods;
602603
}
603-
Method[] methods = (baseType.isInterface() ? baseType.getMethods() : baseType.getDeclaredMethods());
604+
Method[] methods = (ifcCheck ? baseType.getMethods() : baseType.getDeclaredMethods());
604605
for (Method baseMethod : methods) {
605606
try {
606-
if (hasSearchableAnnotations(baseMethod)) {
607+
// Public methods on interfaces (including interface hierarchy),
608+
// non-private (and therefore overridable) methods on base classes
609+
if ((ifcCheck || !Modifier.isPrivate(baseMethod.getModifiers())) &&
610+
hasSearchableAnnotations(baseMethod)) {
607611
if (annotatedMethods == null) {
608612
annotatedMethods = new HashSet<>();
609613
}

spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ public void getDeclaredRepeatableAnnotationsDeclaredOnSuperclass() {
711711
public void getAttributeOverrideNameFromWrongTargetAnnotation() throws Exception {
712712
Method attribute = AliasedComposedContextConfig.class.getDeclaredMethod("xmlConfigFile");
713713
assertThat("xmlConfigFile is not an alias for @Component.",
714-
getAttributeOverrideName(attribute, Component.class), is(nullValue()));
714+
getAttributeOverrideName(attribute, Component.class), is(nullValue()));
715715
}
716716

717717
@Test
@@ -905,7 +905,6 @@ public void synthesizeAnnotationWithAttributeAliasWithoutMirroredAliasFor() thro
905905
public void synthesizeAnnotationWithAttributeAliasWithMirroredAliasForWrongAttribute() throws Exception {
906906
AliasForWithMirroredAliasForWrongAttribute annotation =
907907
AliasForWithMirroredAliasForWrongAttributeClass.class.getAnnotation(AliasForWithMirroredAliasForWrongAttribute.class);
908-
909908
exception.expect(AnnotationConfigurationException.class);
910909
exception.expectMessage(startsWith("Attribute 'bar' in"));
911910
exception.expectMessage(containsString(AliasForWithMirroredAliasForWrongAttribute.class.getName()));
@@ -1013,18 +1012,18 @@ private void assertAnnotationSynthesisWithImplicitAliases(Class<?> clazz, String
10131012
@Test
10141013
public void synthesizeAnnotationWithImplicitAliasesWithImpliedAliasNamesOmitted() throws Exception {
10151014
assertAnnotationSynthesisWithImplicitAliasesWithImpliedAliasNamesOmitted(
1016-
ValueImplicitAliasesWithImpliedAliasNamesOmittedContextConfigClass.class, "value");
1015+
ValueImplicitAliasesWithImpliedAliasNamesOmittedContextConfigClass.class, "value");
10171016
assertAnnotationSynthesisWithImplicitAliasesWithImpliedAliasNamesOmitted(
1018-
LocationsImplicitAliasesWithImpliedAliasNamesOmittedContextConfigClass.class, "location");
1017+
LocationsImplicitAliasesWithImpliedAliasNamesOmittedContextConfigClass.class, "location");
10191018
assertAnnotationSynthesisWithImplicitAliasesWithImpliedAliasNamesOmitted(
1020-
XmlFilesImplicitAliasesWithImpliedAliasNamesOmittedContextConfigClass.class, "xmlFile");
1019+
XmlFilesImplicitAliasesWithImpliedAliasNamesOmittedContextConfigClass.class, "xmlFile");
10211020
}
10221021

1023-
private void assertAnnotationSynthesisWithImplicitAliasesWithImpliedAliasNamesOmitted(Class<?> clazz,
1024-
String expected) throws Exception {
1022+
private void assertAnnotationSynthesisWithImplicitAliasesWithImpliedAliasNamesOmitted(
1023+
Class<?> clazz, String expected) {
10251024

10261025
ImplicitAliasesWithImpliedAliasNamesOmittedContextConfig config = clazz.getAnnotation(
1027-
ImplicitAliasesWithImpliedAliasNamesOmittedContextConfig.class);
1026+
ImplicitAliasesWithImpliedAliasNamesOmittedContextConfig.class);
10281027
assertNotNull(config);
10291028

10301029
ImplicitAliasesWithImpliedAliasNamesOmittedContextConfig synthesizedConfig = synthesizeAnnotation(config);
@@ -1222,7 +1221,6 @@ public void synthesizeAnnotationFromDefaultsWithAttributeAliases() throws Except
12221221
@Test
12231222
public void synthesizeAnnotationWithAttributeAliasesWithDifferentValues() throws Exception {
12241223
ContextConfig contextConfig = synthesizeAnnotation(ContextConfigMismatch.class.getAnnotation(ContextConfig.class));
1225-
12261224
exception.expect(AnnotationConfigurationException.class);
12271225
getValue(contextConfig);
12281226
}

spring-test/src/main/java/org/springframework/test/web/servlet/MockMvc.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public final class MockMvc {
8989
Assert.notNull(servlet, "DispatcherServlet is required");
9090
Assert.notNull(filters, "Filters cannot be null");
9191
Assert.noNullElements(filters, "Filters cannot contain null values");
92+
9293
this.servlet = servlet;
9394
this.filters = filters;
9495
this.servletContext = servlet.getServletContext();
@@ -201,7 +202,6 @@ private void applyDefaultResultActions(MvcResult mvcResult) throws Exception {
201202
for (ResultMatcher matcher : this.defaultResultMatchers) {
202203
matcher.match(mvcResult);
203204
}
204-
205205
for (ResultHandler handler : this.defaultResultHandlers) {
206206
handler.handle(mvcResult);
207207
}

spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ private String getRemainingPath(String requestUri, String mapping, boolean ignor
268268
}
269269
c1 = requestUri.charAt(index1);
270270
}
271-
if (c1 == c2 || ignoreCase && (Character.toLowerCase(c1) == Character.toLowerCase(c2))) {
271+
if (c1 == c2 || (ignoreCase && (Character.toLowerCase(c1) == Character.toLowerCase(c2)))) {
272272
continue;
273273
}
274274
return null;

spring-webmvc/src/main/java/org/springframework/web/servlet/view/ResourceBundleViewResolver.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
public class ResourceBundleViewResolver extends AbstractCachingViewResolver
6464
implements Ordered, InitializingBean, DisposableBean {
6565

66-
/** The default basename if no other basename is supplied. */
66+
/** The default basename if no other basename is supplied */
6767
public static final String DEFAULT_BASENAME = "views";
6868

6969

@@ -77,14 +77,14 @@ public class ResourceBundleViewResolver extends AbstractCachingViewResolver
7777
@Nullable
7878
private Locale[] localesToInitialize;
7979

80+
private int order = Ordered.LOWEST_PRECEDENCE; // default: same as non-Ordered
81+
8082
/* Locale -> BeanFactory */
8183
private final Map<Locale, BeanFactory> localeCache = new HashMap<>();
8284

8385
/* List of ResourceBundle -> BeanFactory */
8486
private final Map<List<ResourceBundle>, ConfigurableApplicationContext> bundleCache = new HashMap<>();
8587

86-
private int order = Ordered.LOWEST_PRECEDENCE; // default: same as non-Ordered
87-
8888

8989
/**
9090
* Set a single basename, following {@link java.util.ResourceBundle} conventions.
@@ -97,7 +97,8 @@ public class ResourceBundleViewResolver extends AbstractCachingViewResolver
9797
* This means that "test.theme" is effectively equivalent to "test/theme",
9898
* just like it is for programmatic {@code java.util.ResourceBundle} usage.
9999
* @see #setBasenames
100-
* @see java.util.ResourceBundle#getBundle(String)
100+
* @see ResourceBundle#getBundle(String)
101+
* @see ResourceBundle#getBundle(String, Locale)
101102
*/
102103
public void setBasename(String basename) {
103104
setBasenames(basename);
@@ -118,7 +119,7 @@ public void setBasename(String basename) {
118119
* This means that "test.theme" is effectively equivalent to "test/theme",
119120
* just like it is for programmatic {@code java.util.ResourceBundle} usage.
120121
* @see #setBasename
121-
* @see java.util.ResourceBundle#getBundle(String)
122+
* @see ResourceBundle#getBundle(String)
122123
*/
123124
public void setBasenames(String... basenames) {
124125
this.basenames = basenames;
@@ -271,7 +272,7 @@ protected synchronized BeanFactory initFactory(Locale locale) throws BeansExcept
271272
* @param locale the {@code Locale} to look for
272273
* @return the corresponding {@code ResourceBundle}
273274
* @throws MissingResourceException if no matching bundle could be found
274-
* @see java.util.ResourceBundle#getBundle(String, java.util.Locale, ClassLoader)
275+
* @see ResourceBundle#getBundle(String, Locale, ClassLoader)
275276
*/
276277
protected ResourceBundle getBundle(String basename, Locale locale) throws MissingResourceException {
277278
return ResourceBundle.getBundle(basename, locale, getBundleClassLoader());

0 commit comments

Comments
 (0)