Skip to content

Commit 5515112

Browse files
committed
Polishing
1 parent 89cadfa commit 5515112

File tree

6 files changed

+32
-38
lines changed

6 files changed

+32
-38
lines changed

spring-aop/src/main/java/org/springframework/aop/config/AopConfigUtils.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -31,11 +31,10 @@
3131
/**
3232
* Utility class for handling registration of AOP auto-proxy creators.
3333
*
34-
* <p>Only a single auto-proxy creator can be registered yet multiple concrete
35-
* implementations are available. Therefore this class wraps a simple escalation
36-
* protocol, allowing classes to request a particular auto-proxy creator and know
37-
* that class, {@code or a subclass thereof}, will eventually be resident
38-
* in the application context.
34+
* <p>Only a single auto-proxy creator should be registered yet multiple concrete
35+
* implementations are available. This class provides a simple escalation protocol,
36+
* allowing a caller to request a particular auto-proxy creator and know that creator,
37+
* <i>or a more capable variant thereof</i>, will be registered as a post-processor.
3938
*
4039
* @author Rob Harrop
4140
* @author Juergen Hoeller
@@ -54,12 +53,10 @@ public abstract class AopConfigUtils {
5453
/**
5554
* Stores the auto proxy creator classes in escalation order.
5655
*/
57-
private static final List<Class<?>> APC_PRIORITY_LIST = new ArrayList<Class<?>>();
56+
private static final List<Class<?>> APC_PRIORITY_LIST = new ArrayList<Class<?>>(3);
5857

59-
/**
60-
* Setup the escalation list.
61-
*/
6258
static {
59+
// Set up the escalation list...
6360
APC_PRIORITY_LIST.add(InfrastructureAdvisorAutoProxyCreator.class);
6461
APC_PRIORITY_LIST.add(AspectJAwareAdvisorAutoProxyCreator.class);
6562
APC_PRIORITY_LIST.add(AnnotationAwareAspectJAutoProxyCreator.class);
@@ -107,6 +104,7 @@ public static void forceAutoProxyCreatorToExposeProxy(BeanDefinitionRegistry reg
107104

108105
private static BeanDefinition registerOrEscalateApcAsRequired(Class<?> cls, BeanDefinitionRegistry registry, Object source) {
109106
Assert.notNull(registry, "BeanDefinitionRegistry must not be null");
107+
110108
if (registry.containsBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME)) {
111109
BeanDefinition apcDefinition = registry.getBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME);
112110
if (!cls.getName().equals(apcDefinition.getBeanClassName())) {
@@ -118,6 +116,7 @@ private static BeanDefinition registerOrEscalateApcAsRequired(Class<?> cls, Bean
118116
}
119117
return null;
120118
}
119+
121120
RootBeanDefinition beanDefinition = new RootBeanDefinition(cls);
122121
beanDefinition.setSource(source);
123122
beanDefinition.getPropertyValues().add("order", Ordered.HIGHEST_PRECEDENCE);

spring-aop/src/main/java/org/springframework/aop/config/AopNamespaceUtils.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -27,11 +27,11 @@
2727
* Utility class for handling registration of auto-proxy creators used internally
2828
* by the '{@code aop}' namespace tags.
2929
*
30-
* <p>Only a single auto-proxy creator can be registered and multiple tags may wish
31-
* to register different concrete implementations. As such this class delegates to
32-
* {@link AopConfigUtils} which wraps a simple escalation protocol. Therefore classes
33-
* may request a particular auto-proxy creator and know that class, <i>or a subclass
34-
* thereof</i>, will eventually be resident in the application context.
30+
* <p>Only a single auto-proxy creator should be registered and multiple configuration
31+
* elements may wish to register different concrete implementations. As such this class
32+
* delegates to {@link AopConfigUtils} which provides a simple escalation protocol.
33+
* Callers may request a particular auto-proxy creator and know that creator,
34+
* <i>or a more capable variant thereof</i>, will be registered as a post-processor.
3535
*
3636
* @author Rob Harrop
3737
* @author Juergen Hoeller
@@ -94,9 +94,8 @@ private static void useClassProxyingIfNecessary(BeanDefinitionRegistry registry,
9494

9595
private static void registerComponentIfNecessary(BeanDefinition beanDefinition, ParserContext parserContext) {
9696
if (beanDefinition != null) {
97-
BeanComponentDefinition componentDefinition =
98-
new BeanComponentDefinition(beanDefinition, AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME);
99-
parserContext.registerComponent(componentDefinition);
97+
parserContext.registerComponent(
98+
new BeanComponentDefinition(beanDefinition, AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME));
10099
}
101100
}
102101

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,7 @@ public void findMethodAnnotationOnBridgeMethod() throws Exception {
144144
assertNull(getAnnotation(bridgeMethod, Order.class));
145145
assertNotNull(findAnnotation(bridgeMethod, Order.class));
146146

147-
// As of OpenJDK 8 b99, invoking getAnnotation() on a bridge method actually finds
148-
// an annotation on its 'bridged' method. This differs from the previous behavior
149-
// of JDK 5 through 7 and from the current behavior of the Eclipse compiler;
150-
// however, we need to ensure that the tests pass in the Gradle build. So we
151-
// comment out the following assertion.
152-
// assertNull(bridgeMethod.getAnnotation(Transactional.class));
147+
assertNotNull(bridgeMethod.getAnnotation(Transactional.class));
153148
assertNotNull(getAnnotation(bridgeMethod, Transactional.class));
154149
assertNotNull(findAnnotation(bridgeMethod, Transactional.class));
155150
}
@@ -285,7 +280,7 @@ public void findClassAnnotationOnSubSubNonInheritedAnnotationInterface() {
285280
}
286281

287282
@Test
288-
public void findAnnotationDeclaringClassForAllScenarios() throws Exception {
283+
public void findAnnotationDeclaringClassForAllScenarios() {
289284
// no class-level annotation
290285
assertNull(findAnnotationDeclaringClass(Transactional.class, NonAnnotatedInterface.class));
291286
assertNull(findAnnotationDeclaringClass(Transactional.class, NonAnnotatedClass.class));
@@ -394,7 +389,7 @@ public void isAnnotationDeclaredLocallyForAllScenarios() throws Exception {
394389
}
395390

396391
@Test
397-
public void isAnnotationInheritedForAllScenarios() throws Exception {
392+
public void isAnnotationInheritedForAllScenarios() {
398393
// no class-level annotation
399394
assertFalse(isAnnotationInherited(Transactional.class, NonAnnotatedInterface.class));
400395
assertFalse(isAnnotationInherited(Transactional.class, NonAnnotatedClass.class));
@@ -503,7 +498,7 @@ public void getDefaultValueFromAnnotation() throws Exception {
503498
}
504499

505500
@Test
506-
public void getDefaultValueFromNonPublicAnnotation() throws Exception {
501+
public void getDefaultValueFromNonPublicAnnotation() {
507502
Annotation[] declaredAnnotations = NonPublicAnnotatedClass.class.getDeclaredAnnotations();
508503
assertEquals(1, declaredAnnotations.length);
509504
Annotation annotation = declaredAnnotations[0];
@@ -514,7 +509,7 @@ public void getDefaultValueFromNonPublicAnnotation() throws Exception {
514509
}
515510

516511
@Test
517-
public void getDefaultValueFromAnnotationType() throws Exception {
512+
public void getDefaultValueFromAnnotationType() {
518513
assertEquals(Ordered.LOWEST_PRECEDENCE, getDefaultValue(Order.class, VALUE));
519514
assertEquals(Ordered.LOWEST_PRECEDENCE, getDefaultValue(Order.class));
520515
}
@@ -546,7 +541,7 @@ public void getRepeatableAnnotationsDeclaredOnClassWithMissingAttributeAliasDecl
546541
}
547542

548543
@Test
549-
public void getRepeatableAnnotationsDeclaredOnClassWithAttributeAliases() throws Exception {
544+
public void getRepeatableAnnotationsDeclaredOnClassWithAttributeAliases() {
550545
final List<String> expectedLocations = asList("A", "B");
551546

552547
Set<ContextConfig> annotations = getRepeatableAnnotations(ConfigHierarchyTestCase.class, ContextConfig.class, null);

spring-web/src/main/java/org/springframework/remoting/caucho/HessianServiceExporter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ public void handleRequest(HttpServletRequest request, HttpServletResponse respon
6363

6464
response.setContentType(CONTENT_TYPE_HESSIAN);
6565
try {
66-
invoke(request.getInputStream(), response.getOutputStream());
66+
invoke(request.getInputStream(), response.getOutputStream());
6767
}
6868
catch (Throwable ex) {
69-
throw new NestedServletException("Hessian skeleton invocation failed", ex);
69+
throw new NestedServletException("Hessian skeleton invocation failed", ex);
7070
}
7171
}
7272

spring-web/src/main/java/org/springframework/remoting/jaxws/SimpleHttpServerJaxWsServiceExporter.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -157,11 +157,12 @@ public void afterPropertiesSet() throws Exception {
157157
if (this.server == null) {
158158
InetSocketAddress address = (this.hostname != null ?
159159
new InetSocketAddress(this.hostname, this.port) : new InetSocketAddress(this.port));
160-
this.server = HttpServer.create(address, this.backlog);
161-
if (this.logger.isInfoEnabled()) {
162-
this.logger.info("Starting HttpServer at address " + address);
160+
HttpServer server = HttpServer.create(address, this.backlog);
161+
if (logger.isInfoEnabled()) {
162+
logger.info("Starting HttpServer at address " + address);
163163
}
164-
this.server.start();
164+
server.start();
165+
this.server = server;
165166
this.localServer = true;
166167
}
167168
super.afterPropertiesSet();

spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ private boolean tryFlushMessageBuffer() throws IOException {
156156
}
157157
finally {
158158
this.sendStartTime = 0;
159-
flushLock.unlock();
159+
this.flushLock.unlock();
160160
}
161161
return true;
162162
}

0 commit comments

Comments
 (0)