Skip to content

Commit 0f71f58

Browse files
committed
Polishing
1 parent 9834c42 commit 0f71f58

File tree

10 files changed

+62
-67
lines changed

10 files changed

+62
-67
lines changed

spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CacheResultInterceptor.java

Lines changed: 6 additions & 6 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.
@@ -39,6 +39,7 @@ public CacheResultInterceptor(CacheErrorHandler errorHandler) {
3939
super(errorHandler);
4040
}
4141

42+
4243
@Override
4344
protected Object invoke(CacheOperationInvocationContext<CacheResultOperation> context,
4445
CacheOperationInvoker invoker) {
@@ -82,7 +83,6 @@ protected void checkForCachedException(Cache exceptionCache, Object cacheKey) {
8283
}
8384
}
8485

85-
8686
protected void cacheException(Cache exceptionCache, ExceptionTypeFilter filter, Object cacheKey, Throwable ex) {
8787
if (exceptionCache == null) {
8888
return;
@@ -92,7 +92,6 @@ protected void cacheException(Cache exceptionCache, ExceptionTypeFilter filter,
9292
}
9393
}
9494

95-
9695
private Cache resolveExceptionCache(CacheOperationInvocationContext<CacheResultOperation> context) {
9796
CacheResolver exceptionCacheResolver = context.getOperation().getExceptionCacheResolver();
9897
if (exceptionCacheResolver != null) {
@@ -101,18 +100,19 @@ private Cache resolveExceptionCache(CacheOperationInvocationContext<CacheResultO
101100
return null;
102101
}
103102

103+
104104
/**
105105
* Rewrite the call stack of the specified {@code exception} so that it matches
106-
* the current call stack up-to (included) the specified method invocation.
106+
* the current call stack up to (included) the specified method invocation.
107107
* <p>Clone the specified exception. If the exception is not {@code serializable},
108108
* the original exception is returned. If no common ancestor can be found, returns
109109
* the original exception.
110110
* <p>Used to make sure that a cached exception has a valid invocation context.
111111
* @param exception the exception to merge with the current call stack
112112
* @param className the class name of the common ancestor
113113
* @param methodName the method name of the common ancestor
114-
* @return a clone exception with a rewritten call stack composed of the current
115-
* call stack up to (included) the common ancestor specified by the {@code className} and
114+
* @return a clone exception with a rewritten call stack composed of the current call
115+
* stack up to (included) the common ancestor specified by the {@code className} and
116116
* {@code methodName} arguments, followed by stack trace elements of the specified
117117
* {@code exception} after the common ancestor.
118118
*/

spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheErrorHandlerTests.java

Lines changed: 19 additions & 25 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.
@@ -49,9 +49,6 @@
4949
*/
5050
public class JCacheErrorHandlerTests {
5151

52-
@Rule
53-
public final ExpectedException thrown = ExpectedException.none();
54-
5552
private Cache cache;
5653

5754
private Cache errorCache;
@@ -60,20 +57,23 @@ public class JCacheErrorHandlerTests {
6057

6158
private SimpleService simpleService;
6259

60+
@Rule
61+
public final ExpectedException thrown = ExpectedException.none();
62+
63+
6364
@Before
6465
public void setup() {
65-
AnnotationConfigApplicationContext context =
66-
new AnnotationConfigApplicationContext(Config.class);
66+
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
6767
this.cache = context.getBean("mockCache", Cache.class);
6868
this.errorCache = context.getBean("mockErrorCache", Cache.class);
6969
this.errorHandler = context.getBean(CacheErrorHandler.class);
7070
this.simpleService = context.getBean(SimpleService.class);
7171
}
7272

73+
7374
@Test
7475
public void getFail() {
75-
UnsupportedOperationException exception =
76-
new UnsupportedOperationException("Test exception on get");
76+
UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on get");
7777
Object key = SimpleKeyGenerator.generateKey(0L);
7878
willThrow(exception).given(this.cache).get(key);
7979

@@ -83,8 +83,7 @@ public void getFail() {
8383

8484
@Test
8585
public void getPutNewElementFail() {
86-
UnsupportedOperationException exception =
87-
new UnsupportedOperationException("Test exception on put");
86+
UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on put");
8887
Object key = SimpleKeyGenerator.generateKey(0L);
8988
given(this.cache.get(key)).willReturn(null);
9089
willThrow(exception).given(this.cache).put(key, 0L);
@@ -95,27 +94,24 @@ public void getPutNewElementFail() {
9594

9695
@Test
9796
public void getFailPutExceptionFail() {
98-
UnsupportedOperationException exceptionOnPut =
99-
new UnsupportedOperationException("Test exception on put");
97+
UnsupportedOperationException exceptionOnPut = new UnsupportedOperationException("Test exception on put");
10098
Object key = SimpleKeyGenerator.generateKey(0L);
10199
given(this.cache.get(key)).willReturn(null);
102-
willThrow(exceptionOnPut).given(this.errorCache).put(key,
103-
SimpleService.TEST_EXCEPTION);
100+
willThrow(exceptionOnPut).given(this.errorCache).put(key, SimpleService.TEST_EXCEPTION);
104101

105102
try {
106103
this.simpleService.getFail(0L);
107104
}
108105
catch (IllegalStateException ex) {
109106
assertEquals("Test exception", ex.getMessage());
110107
}
111-
verify(this.errorHandler).handleCachePutError(exceptionOnPut,
112-
this.errorCache, key, SimpleService.TEST_EXCEPTION);
108+
verify(this.errorHandler).handleCachePutError(
109+
exceptionOnPut, this.errorCache, key, SimpleService.TEST_EXCEPTION);
113110
}
114111

115112
@Test
116113
public void putFail() {
117-
UnsupportedOperationException exception =
118-
new UnsupportedOperationException("Test exception on put");
114+
UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on put");
119115
Object key = SimpleKeyGenerator.generateKey(0L);
120116
willThrow(exception).given(this.cache).put(key, 234L);
121117

@@ -125,8 +121,7 @@ public void putFail() {
125121

126122
@Test
127123
public void evictFail() {
128-
UnsupportedOperationException exception =
129-
new UnsupportedOperationException("Test exception on evict");
124+
UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on evict");
130125
Object key = SimpleKeyGenerator.generateKey(0L);
131126
willThrow(exception).given(this.cache).evict(key);
132127

@@ -136,8 +131,7 @@ public void evictFail() {
136131

137132
@Test
138133
public void clearFail() {
139-
UnsupportedOperationException exception =
140-
new UnsupportedOperationException("Test exception on evict");
134+
UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on evict");
141135
willThrow(exception).given(this.cache).clear();
142136

143137
this.simpleService.clear();
@@ -181,14 +175,13 @@ public Cache mockErrorCache() {
181175
given(cache.getName()).willReturn("error");
182176
return cache;
183177
}
184-
185178
}
186179

180+
187181
@CacheDefaults(cacheName = "test")
188182
public static class SimpleService {
189183

190-
private static final IllegalStateException TEST_EXCEPTION =
191-
new IllegalStateException("Test exception");
184+
private static final IllegalStateException TEST_EXCEPTION = new IllegalStateException("Test exception");
192185

193186
private AtomicLong counter = new AtomicLong();
194187

@@ -214,4 +207,5 @@ public void evict(long id) {
214207
public void clear() {
215208
}
216209
}
210+
217211
}

spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationPostProcessor.java

Lines changed: 2 additions & 1 deletion
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.
@@ -55,6 +55,7 @@
5555
* @author Juergen Hoeller
5656
* @since 3.1
5757
* @see MethodValidationInterceptor
58+
* @see javax.validation.executable.ExecutableValidator
5859
* @see org.hibernate.validator.method.MethodValidator
5960
*/
6061
@SuppressWarnings("serial")

spring-jdbc/src/main/java/org/springframework/jdbc/datasource/JdbcTransactionObjectSupport.java

Lines changed: 10 additions & 11 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.
@@ -31,19 +31,18 @@
3131
import org.springframework.transaction.support.SmartTransactionObject;
3232

3333
/**
34-
* Convenient base class for JDBC-aware transaction objects.
35-
* Can contain a {@link ConnectionHolder}, and implements the
36-
* {@link org.springframework.transaction.SavepointManager}
37-
* interface based on that ConnectionHolder.
34+
* Convenient base class for JDBC-aware transaction objects. Can contain a
35+
* {@link ConnectionHolder} with a JDBC {@code Connection}, and implements the
36+
* {@link SavepointManager} interface based on that {@code ConnectionHolder}.
3837
*
39-
* <p>Allows for programmatic management of JDBC 3.0
40-
* {@link java.sql.Savepoint Savepoints}. Spring's
41-
* {@link org.springframework.transaction.support.DefaultTransactionStatus}
42-
* will automatically delegate to this, as it autodetects transaction
43-
* objects that implement the SavepointManager interface.
38+
* <p>Allows for programmatic management of JDBC {@link java.sql.Savepoint Savepoints}.
39+
* Spring's {@link org.springframework.transaction.support.DefaultTransactionStatus}
40+
* automatically delegates to this, as it autodetects transaction objects which
41+
* implement the {@link SavepointManager} interface.
4442
*
4543
* @author Juergen Hoeller
4644
* @since 1.1
45+
* @see DataSourceTransactionManager
4746
*/
4847
public abstract class JdbcTransactionObjectSupport implements SavepointManager, SmartTransactionObject {
4948

@@ -151,7 +150,7 @@ protected ConnectionHolder getConnectionHolderForSavepoint() throws TransactionE
151150
}
152151
if (!hasConnectionHolder()) {
153152
throw new TransactionUsageException(
154-
"Cannot create nested transaction if not exposing a JDBC transaction");
153+
"Cannot create nested transaction when not exposing a JDBC transaction");
155154
}
156155
return getConnectionHolder();
157156
}

spring-tx/src/main/java/org/springframework/transaction/support/ResourceHolderSupport.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 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.
@@ -23,9 +23,9 @@
2323
/**
2424
* Convenient base class for resource holders.
2525
*
26-
* <p>Features rollback-only support for nested transactions.
27-
* Can expire after a certain number of seconds or milliseconds,
28-
* to determine transactional timeouts.
26+
* <p>Features rollback-only support for participating transactions.
27+
* Can expire after a certain number of seconds or milliseconds
28+
* in order to determine a transactional timeout.
2929
*
3030
* @author Juergen Hoeller
3131
* @since 02.02.2004

spring-web/src/main/java/org/springframework/http/client/Netty4ClientHttpRequest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ private FullHttpRequest createFullHttpRequest(HttpHeaders headers) {
141141
for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
142142
nettyRequest.headers().add(entry.getKey(), entry.getValue());
143143
}
144-
if (!nettyRequest.headers().contains(HttpHeaders.CONTENT_LENGTH)
145-
&& this.body.buffer().readableBytes() > 0) {
144+
if (!nettyRequest.headers().contains(HttpHeaders.CONTENT_LENGTH) && this.body.buffer().readableBytes() > 0) {
146145
nettyRequest.headers().set(HttpHeaders.CONTENT_LENGTH, this.body.buffer().readableBytes());
147146
}
148147

spring-web/src/main/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessor.java

Lines changed: 2 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.
@@ -54,8 +54,7 @@
5454
* @author Rossen Stoyanchev
5555
* @since 3.1
5656
*/
57-
public class ModelAttributeMethodProcessor
58-
implements HandlerMethodArgumentResolver, HandlerMethodReturnValueHandler {
57+
public class ModelAttributeMethodProcessor implements HandlerMethodArgumentResolver, HandlerMethodReturnValueHandler {
5958

6059
protected final Log logger = LogFactory.getLog(getClass());
6160

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodArgumentResolver.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.
@@ -251,7 +251,7 @@ protected ServletServerHttpRequest createInputMessage(NativeWebRequest webReques
251251
}
252252

253253
/**
254-
* Validate the request part if applicable.
254+
* Validate the binding target if applicable.
255255
* <p>The default implementation checks for {@code @javax.validation.Valid},
256256
* Spring's {@link org.springframework.validation.annotation.Validated},
257257
* and custom annotations whose name starts with "Valid".

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletInvocableHandlerMethod.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.
@@ -110,8 +110,8 @@ public void setHandlerMethodReturnValueHandlers(HandlerMethodReturnValueHandlerC
110110
* @param mavContainer the ModelAndViewContainer for this request
111111
* @param providedArgs "given" arguments matched by type (not resolved)
112112
*/
113-
public void invokeAndHandle(ServletWebRequest webRequest,
114-
ModelAndViewContainer mavContainer, Object... providedArgs) throws Exception {
113+
public void invokeAndHandle(ServletWebRequest webRequest, ModelAndViewContainer mavContainer,
114+
Object... providedArgs) throws Exception {
115115

116116
Object returnValue = invokeForRequest(webRequest, mavContainer, providedArgs);
117117
setResponseStatus(webRequest);

0 commit comments

Comments
 (0)