Skip to content

Commit b945e0f

Browse files
committed
Polishing
(cherry picked from commit 6d6cf01)
1 parent ce3cf32 commit b945e0f

File tree

6 files changed

+46
-49
lines changed

6 files changed

+46
-49
lines changed

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

Lines changed: 3 additions & 3 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-2017 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.
@@ -322,7 +322,7 @@ public Object postProcessAfterInitialization(Object bean, String beanName) {
322322
if (bean != null && !(bean instanceof BeanPostProcessor) && !isInfrastructureBean(beanName) &&
323323
this.beanFactory.getBeanPostProcessorCount() < this.beanPostProcessorTargetCount) {
324324
if (logger.isInfoEnabled()) {
325-
logger.info("Bean '" + beanName + "' of type [" + bean.getClass() +
325+
logger.info("Bean '" + beanName + "' of type [" + bean.getClass().getName() +
326326
"] is not eligible for getting processed by all BeanPostProcessors " +
327327
"(for example: not eligible for auto-proxying)");
328328
}
@@ -333,7 +333,7 @@ public Object postProcessAfterInitialization(Object bean, String beanName) {
333333
private boolean isInfrastructureBean(String beanName) {
334334
if (beanName != null && this.beanFactory.containsBeanDefinition(beanName)) {
335335
BeanDefinition bd = this.beanFactory.getBeanDefinition(beanName);
336-
return RootBeanDefinition.ROLE_INFRASTRUCTURE == bd.getRole();
336+
return (bd.getRole() == RootBeanDefinition.ROLE_INFRASTRUCTURE);
337337
}
338338
return false;
339339
}

spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncAnnotationAdvisor.java

Lines changed: 4 additions & 3 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-2017 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.
@@ -159,11 +159,12 @@ protected Pointcut buildPointcut(Set<Class<? extends Annotation>> asyncAnnotatio
159159
Pointcut cpc = new AnnotationMatchingPointcut(asyncAnnotationType, true);
160160
Pointcut mpc = AnnotationMatchingPointcut.forMethodAnnotation(asyncAnnotationType);
161161
if (result == null) {
162-
result = new ComposablePointcut(cpc).union(mpc);
162+
result = new ComposablePointcut(cpc);
163163
}
164164
else {
165-
result.union(cpc).union(mpc);
165+
result.union(cpc);
166166
}
167+
result = result.union(mpc);
167168
}
168169
return result;
169170
}

spring-context/src/test/java/org/springframework/cache/config/CacheableService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2017 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.
@@ -17,7 +17,7 @@
1717
package org.springframework.cache.config;
1818

1919
/**
20-
* Basic service interface.
20+
* Basic service interface for caching tests.
2121
*
2222
* @author Costin Leau
2323
* @author Phillip Webb
@@ -83,7 +83,6 @@ public interface CacheableService<T> {
8383

8484
T throwUncheckedSync(Object arg1);
8585

86-
// multi annotations
8786
T multiCache(Object arg1);
8887

8988
T multiEvict(Object arg1);
@@ -95,4 +94,5 @@ public interface CacheableService<T> {
9594
T multiUpdate(Object arg1);
9695

9796
TestEntity putRefersToResult(TestEntity arg1);
97+
9898
}

spring-context/src/test/java/org/springframework/cache/config/DefaultCacheableService.java

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2017 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,7 +25,7 @@
2525
import org.springframework.cache.annotation.Caching;
2626

2727
/**
28-
* Simple cacheable service
28+
* Simple cacheable service.
2929
*
3030
* @author Costin Leau
3131
* @author Phillip Webb
@@ -34,12 +34,14 @@
3434
public class DefaultCacheableService implements CacheableService<Long> {
3535

3636
private final AtomicLong counter = new AtomicLong();
37+
3738
private final AtomicLong nullInvocations = new AtomicLong();
3839

40+
3941
@Override
4042
@Cacheable("testCache")
4143
public Long cache(Object arg1) {
42-
return counter.getAndIncrement();
44+
return this.counter.getAndIncrement();
4345
}
4446

4547
@Override
@@ -51,7 +53,7 @@ public Long cacheNull(Object arg1) {
5153
@Override
5254
@Cacheable(cacheNames = "testCache", sync = true)
5355
public Long cacheSync(Object arg1) {
54-
return counter.getAndIncrement();
56+
return this.counter.getAndIncrement();
5557
}
5658

5759
@Override
@@ -96,13 +98,13 @@ public void invalidateEarly(Object arg1, Object arg2) {
9698
@Override
9799
@Cacheable(cacheNames = "testCache", condition = "#p0 == 3")
98100
public Long conditional(int classField) {
99-
return counter.getAndIncrement();
101+
return this.counter.getAndIncrement();
100102
}
101103

102104
@Override
103105
@Cacheable(cacheNames = "testCache", sync = true, condition = "#p0 == 3")
104106
public Long conditionalSync(int classField) {
105-
return counter.getAndIncrement();
107+
return this.counter.getAndIncrement();
106108
}
107109

108110
@Override
@@ -114,55 +116,55 @@ public Long unless(int arg) {
114116
@Override
115117
@Cacheable(cacheNames = "testCache", key = "#p0")
116118
public Long key(Object arg1, Object arg2) {
117-
return counter.getAndIncrement();
119+
return this.counter.getAndIncrement();
118120
}
119121

120122
@Override
121123
@Cacheable(cacheNames = "testCache")
122124
public Long varArgsKey(Object... args) {
123-
return counter.getAndIncrement();
125+
return this.counter.getAndIncrement();
124126
}
125127

126128
@Override
127129
@Cacheable(cacheNames = "testCache", key = "#root.methodName")
128130
public Long name(Object arg1) {
129-
return counter.getAndIncrement();
131+
return this.counter.getAndIncrement();
130132
}
131133

132134
@Override
133135
@Cacheable(cacheNames = "testCache", key = "#root.methodName + #root.method.name + #root.targetClass + #root.target")
134136
public Long rootVars(Object arg1) {
135-
return counter.getAndIncrement();
137+
return this.counter.getAndIncrement();
136138
}
137139

138140
@Override
139141
@Cacheable(cacheNames = "testCache", keyGenerator = "customKeyGenerator")
140142
public Long customKeyGenerator(Object arg1) {
141-
return counter.getAndIncrement();
143+
return this.counter.getAndIncrement();
142144
}
143145

144146
@Override
145147
@Cacheable(cacheNames = "testCache", keyGenerator = "unknownBeanName")
146148
public Long unknownCustomKeyGenerator(Object arg1) {
147-
return counter.getAndIncrement();
149+
return this.counter.getAndIncrement();
148150
}
149151

150152
@Override
151153
@Cacheable(cacheNames = "testCache", cacheManager = "customCacheManager")
152154
public Long customCacheManager(Object arg1) {
153-
return counter.getAndIncrement();
155+
return this.counter.getAndIncrement();
154156
}
155157

156158
@Override
157159
@Cacheable(cacheNames = "testCache", cacheManager = "unknownBeanName")
158160
public Long unknownCustomCacheManager(Object arg1) {
159-
return counter.getAndIncrement();
161+
return this.counter.getAndIncrement();
160162
}
161163

162164
@Override
163165
@CachePut("testCache")
164166
public Long update(Object arg1) {
165-
return counter.getAndIncrement();
167+
return this.counter.getAndIncrement();
166168
}
167169

168170
@Override
@@ -174,13 +176,13 @@ public Long conditionalUpdate(Object arg) {
174176
@Override
175177
@Cacheable("testCache")
176178
public Long nullValue(Object arg1) {
177-
nullInvocations.incrementAndGet();
179+
this.nullInvocations.incrementAndGet();
178180
return null;
179181
}
180182

181183
@Override
182184
public Number nullInvocations() {
183-
return nullInvocations.get();
185+
return this.nullInvocations.get();
184186
}
185187

186188
@Override
@@ -212,25 +214,25 @@ public Long throwUncheckedSync(Object arg1) {
212214
@Override
213215
@Caching(cacheable = { @Cacheable("primary"), @Cacheable("secondary") })
214216
public Long multiCache(Object arg1) {
215-
return counter.getAndIncrement();
217+
return this.counter.getAndIncrement();
216218
}
217219

218220
@Override
219221
@Caching(evict = { @CacheEvict("primary"), @CacheEvict(cacheNames = "secondary", key = "#p0"), @CacheEvict(cacheNames = "primary", key = "#p0 + 'A'") })
220222
public Long multiEvict(Object arg1) {
221-
return counter.getAndIncrement();
223+
return this.counter.getAndIncrement();
222224
}
223225

224226
@Override
225227
@Caching(cacheable = { @Cacheable(cacheNames = "primary", key = "#root.methodName") }, evict = { @CacheEvict("secondary") })
226228
public Long multiCacheAndEvict(Object arg1) {
227-
return counter.getAndIncrement();
229+
return this.counter.getAndIncrement();
228230
}
229231

230232
@Override
231233
@Caching(cacheable = { @Cacheable(cacheNames = "primary", condition = "#p0 == 3") }, evict = { @CacheEvict("secondary") })
232234
public Long multiConditionalCacheAndEvict(Object arg1) {
233-
return counter.getAndIncrement();
235+
return this.counter.getAndIncrement();
234236
}
235237

236238
@Override

spring-context/src/test/java/org/springframework/cache/config/EnableCachingTests.java

Lines changed: 11 additions & 17 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-2017 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.
@@ -39,7 +39,8 @@
3939
import static org.junit.Assert.*;
4040

4141
/**
42-
* Integration tests for @EnableCaching and its related @Configuration classes.
42+
* Integration tests for {@code @EnableCaching} and its related
43+
* {@code @Configuration} classes.
4344
*
4445
* @author Chris Beams
4546
* @author Stephane Nicoll
@@ -54,18 +55,16 @@ protected ConfigurableApplicationContext getApplicationContext() {
5455

5556
@Test
5657
public void testKeyStrategy() {
57-
CacheInterceptor ci = ctx.getBean(CacheInterceptor.class);
58-
assertSame(ctx.getBean("keyGenerator", KeyGenerator.class), ci.getKeyGenerator());
58+
CacheInterceptor ci = this.ctx.getBean(CacheInterceptor.class);
59+
assertSame(this.ctx.getBean("keyGenerator", KeyGenerator.class), ci.getKeyGenerator());
5960
}
6061

6162
@Test
6263
public void testCacheErrorHandler() {
63-
CacheInterceptor ci = ctx.getBean(CacheInterceptor.class);
64-
assertSame(ctx.getBean("errorHandler", CacheErrorHandler.class), ci.getErrorHandler());
64+
CacheInterceptor ci = this.ctx.getBean(CacheInterceptor.class);
65+
assertSame(this.ctx.getBean("errorHandler", CacheErrorHandler.class), ci.getErrorHandler());
6566
}
6667

67-
// --- local tests -------
68-
6968
@Test
7069
public void singleCacheManagerBean() throws Throwable {
7170
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
@@ -91,7 +90,7 @@ public void multipleCacheManagerBeans() throws Throwable {
9190
public void multipleCacheManagerBeans_implementsCachingConfigurer() {
9291
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
9392
ctx.register(MultiCacheManagerConfigurer.class);
94-
ctx.refresh(); // does not throw
93+
ctx.refresh(); // does not throw an exception
9594
}
9695

9796
@Test(expected = IllegalStateException.class)
@@ -124,22 +123,17 @@ public void noCacheManagerBeans() throws Throwable {
124123

125124
@Test
126125
public void emptyConfigSupport() {
127-
ConfigurableApplicationContext context =
128-
new AnnotationConfigApplicationContext(EmptyConfigSupportConfig.class);
129-
126+
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(EmptyConfigSupportConfig.class);
130127
CacheInterceptor ci = context.getBean(CacheInterceptor.class);
131128
assertNotNull(ci.getCacheResolver());
132129
assertEquals(SimpleCacheResolver.class, ci.getCacheResolver().getClass());
133-
assertSame(context.getBean(CacheManager.class),
134-
((SimpleCacheResolver)ci.getCacheResolver()).getCacheManager());
130+
assertSame(context.getBean(CacheManager.class), ((SimpleCacheResolver)ci.getCacheResolver()).getCacheManager());
135131
context.close();
136132
}
137133

138134
@Test
139135
public void bothSetOnlyResolverIsUsed() {
140-
ConfigurableApplicationContext context =
141-
new AnnotationConfigApplicationContext(FullCachingConfig.class);
142-
136+
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(FullCachingConfig.class);
143137
CacheInterceptor ci = context.getBean(CacheInterceptor.class);
144138
assertSame(context.getBean("cacheResolver"), ci.getCacheResolver());
145139
assertSame(context.getBean("keyGenerator"), ci.getKeyGenerator());

spring-jdbc/src/main/java/org/springframework/jdbc/support/JdbcUtils.java

Lines changed: 2 additions & 2 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-2017 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.
@@ -481,7 +481,7 @@ public static String convertUnderscoreNameToPropertyName(String name) {
481481
StringBuilder result = new StringBuilder();
482482
boolean nextIsUpper = false;
483483
if (name != null && name.length() > 0) {
484-
if (name.length() > 1 && name.substring(1,2).equals("_")) {
484+
if (name.length() > 1 && name.substring(1, 2).equals("_")) {
485485
result.append(name.substring(0, 1).toUpperCase());
486486
}
487487
else {

0 commit comments

Comments
 (0)