Skip to content

Commit 020e51c

Browse files
committed
Polishing
(cherry picked from commit 94a7624)
1 parent a780668 commit 020e51c

File tree

8 files changed

+52
-49
lines changed

8 files changed

+52
-49
lines changed

spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationAttributesReadingVisitor.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.
@@ -99,13 +99,14 @@ private void recursivelyCollectMetaAnnotations(Set<Annotation> visited, Annotati
9999
// accessibility in a SecurityManager environment.
100100
if (Modifier.isPublic(annotation.annotationType().getModifiers())) {
101101
String annotationName = annotation.annotationType().getName();
102-
this.attributesMap.add(annotationName, AnnotationUtils.getAnnotationAttributes(annotation, false, true));
102+
this.attributesMap.add(annotationName,
103+
AnnotationUtils.getAnnotationAttributes(annotation, false, true));
103104
}
104105
for (Annotation metaMetaAnnotation : annotation.annotationType().getAnnotations()) {
105106
recursivelyCollectMetaAnnotations(visited, metaMetaAnnotation);
106107
}
107108
}
108-
catch (Exception ex) {
109+
catch (Throwable ex) {
109110
if (logger.isDebugEnabled()) {
110111
logger.debug("Failed to introspect meta-annotations on [" + annotation + "]: " + ex);
111112
}

spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationReadingVisitorUtils.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.
@@ -94,7 +94,7 @@ else if (value instanceof Class[]) {
9494
}
9595
entry.setValue(value);
9696
}
97-
catch (Exception ex) {
97+
catch (Throwable ex) {
9898
// Class not found - can't resolve class reference in annotation attribute.
9999
result.put(entry.getKey(), ex);
100100
}

spring-web/src/test/java/org/springframework/web/context/request/RequestScopeTests.java

Lines changed: 3 additions & 2 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.
@@ -46,7 +46,7 @@ public class RequestScopeTests {
4646

4747

4848
@Before
49-
public void setUp() throws Exception {
49+
public void setup() throws Exception {
5050
this.beanFactory.registerScope("request", new RequestScope());
5151
this.beanFactory.setBeanExpressionResolver(new StandardBeanExpressionResolver());
5252
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
@@ -59,6 +59,7 @@ public void resetRequestAttributes() {
5959
RequestContextHolder.setRequestAttributes(null);
6060
}
6161

62+
6263
@Test
6364
public void getFromScope() throws Exception {
6465
MockHttpServletRequest request = new MockHttpServletRequest();

spring-web/src/test/java/org/springframework/web/context/request/RequestScopedProxyTests.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 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.
@@ -38,17 +38,18 @@
3838
*/
3939
public class RequestScopedProxyTests {
4040

41-
private DefaultListableBeanFactory beanFactory;
41+
private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
42+
4243

4344
@Before
44-
public void setUp() throws Exception {
45-
this.beanFactory = new DefaultListableBeanFactory();
45+
public void setup() {
4646
this.beanFactory.registerScope("request", new RequestScope());
4747
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
4848
reader.loadBeanDefinitions(new ClassPathResource("requestScopedProxyTests.xml", getClass()));
4949
this.beanFactory.preInstantiateSingletons();
5050
}
5151

52+
5253
@Test
5354
public void testGetFromScope() throws Exception {
5455
String name = "requestScopedObject";

spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestHttpMethodsTests.java

Lines changed: 9 additions & 9 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.
@@ -16,8 +16,6 @@
1616

1717
package org.springframework.web.context.request;
1818

19-
import static org.junit.Assert.*;
20-
2119
import java.text.SimpleDateFormat;
2220
import java.util.Arrays;
2321
import java.util.Date;
@@ -34,6 +32,8 @@
3432
import org.springframework.mock.web.test.MockHttpServletRequest;
3533
import org.springframework.mock.web.test.MockHttpServletResponse;
3634

35+
import static org.junit.Assert.*;
36+
3737
/**
3838
* Parameterized tests for ServletWebRequest
3939
* @author Juergen Hoeller
@@ -66,8 +66,9 @@ static public Iterable<Object[]> safeMethods() {
6666
});
6767
}
6868

69+
6970
@Before
70-
public void setUp() {
71+
public void setup() {
7172
currentDate = new Date();
7273
dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
7374
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
@@ -76,6 +77,7 @@ public void setUp() {
7677
request = new ServletWebRequest(servletRequest, servletResponse);
7778
}
7879

80+
7981
@Test
8082
public void checkNotModifiedNon2xxStatus() {
8183
long epochTime = currentDate.getTime();
@@ -87,8 +89,7 @@ public void checkNotModifiedNon2xxStatus() {
8789
assertNull(servletResponse.getHeader("Last-Modified"));
8890
}
8991

90-
// SPR-13516
91-
@Test
92+
@Test // SPR-13516
9293
public void checkNotModifiedInvalidStatus() {
9394
long epochTime = currentDate.getTime();
9495
servletRequest.addHeader("If-Modified-Since", epochTime);
@@ -97,7 +98,7 @@ public void checkNotModifiedInvalidStatus() {
9798
assertFalse(request.checkNotModified(epochTime));
9899
}
99100

100-
@Test // SPR-14559
101+
@Test // SPR-14559
101102
public void checkNotModifiedInvalidIfNoneMatchHeader() {
102103
String eTag = "\"etagvalue\"";
103104
servletRequest.addHeader("If-None-Match", "missingquotes");
@@ -223,8 +224,7 @@ public void checkNotModifiedETagAndTimestamp() {
223224
assertEquals(dateFormat.format(currentDate.getTime()), servletResponse.getHeader("Last-Modified"));
224225
}
225226

226-
// SPR-14224
227-
@Test
227+
@Test // SPR-14224
228228
public void checkNotModifiedETagAndModifiedTimestamp() {
229229
String eTag = "\"Foo\"";
230230
servletRequest.addHeader("If-None-Match", eTag);

spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestTests.java

Lines changed: 7 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.
@@ -16,11 +16,8 @@
1616

1717
package org.springframework.web.context.request;
1818

19-
import static org.junit.Assert.*;
20-
2119
import java.util.Locale;
2220
import java.util.Map;
23-
2421
import javax.servlet.ServletRequest;
2522
import javax.servlet.ServletResponse;
2623
import javax.servlet.http.HttpServletRequest;
@@ -35,6 +32,8 @@
3532
import org.springframework.mock.web.test.MockHttpServletResponse;
3633
import org.springframework.web.multipart.MultipartRequest;
3734

35+
import static org.junit.Assert.*;
36+
3837
/**
3938
* @author Juergen Hoeller
4039
*/
@@ -46,13 +45,15 @@ public class ServletWebRequestTests {
4645

4746
private ServletWebRequest request;
4847

48+
4949
@Before
50-
public void setUp() {
50+
public void setup() {
5151
servletRequest = new MockHttpServletRequest();
5252
servletResponse = new MockHttpServletResponse();
5353
request = new ServletWebRequest(servletRequest, servletResponse);
5454
}
5555

56+
5657
@Test
5758
public void parameters() {
5859
servletRequest.addParameter("param1", "value1");
@@ -114,4 +115,4 @@ public void decoratedNativeRequest() {
114115
assertNull(request.getNativeResponse(MultipartRequest.class));
115116
}
116117

117-
}
118+
}

spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTests.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 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.
@@ -44,7 +44,7 @@ public class WebAsyncManagerTests {
4444

4545

4646
@Before
47-
public void setUp() {
47+
public void setup() {
4848
this.servletRequest = new MockHttpServletRequest();
4949
this.asyncManager = WebAsyncUtils.getAsyncManager(servletRequest);
5050
this.asyncManager.setTaskExecutor(new SyncTaskExecutor());
@@ -54,6 +54,7 @@ public void setUp() {
5454
reset(this.asyncWebRequest);
5555
}
5656

57+
5758
@Test
5859
public void startAsyncProcessingWithoutAsyncWebRequest() throws Exception {
5960
WebAsyncManager manager = WebAsyncUtils.getAsyncManager(new MockHttpServletRequest());
@@ -87,7 +88,7 @@ public void isConcurrentHandlingStarted() {
8788
assertTrue(this.asyncManager.isConcurrentHandlingStarted());
8889
}
8990

90-
@Test(expected=IllegalArgumentException.class)
91+
@Test(expected = IllegalArgumentException.class)
9192
public void setAsyncWebRequestAfterAsyncStarted() {
9293
this.asyncWebRequest.startAsync();
9394
this.asyncManager.setAsyncWebRequest(null);
@@ -233,7 +234,7 @@ public void startCallableProcessingWithAsyncTask() throws Exception {
233234
given(this.asyncWebRequest.getNativeRequest(HttpServletRequest.class)).willReturn(this.servletRequest);
234235

235236
@SuppressWarnings("unchecked")
236-
WebAsyncTask<Object> asyncTask = new WebAsyncTask<Object>(1000L, executor, mock(Callable.class));
237+
WebAsyncTask<Object> asyncTask = new WebAsyncTask<>(1000L, executor, mock(Callable.class));
237238
this.asyncManager.startCallableProcessing(asyncTask);
238239

239240
verify(executor).submit((Runnable) notNull());
@@ -256,7 +257,7 @@ public void startCallableProcessingNullInput() throws Exception {
256257

257258
@Test
258259
public void startDeferredResultProcessing() throws Exception {
259-
DeferredResult<String> deferredResult = new DeferredResult<String>(1000L);
260+
DeferredResult<String> deferredResult = new DeferredResult<>(1000L);
260261
String concurrentResult = "abc";
261262

262263
DeferredResultProcessingInterceptor interceptor = mock(DeferredResultProcessingInterceptor.class);
@@ -278,7 +279,7 @@ public void startDeferredResultProcessing() throws Exception {
278279

279280
@Test
280281
public void startDeferredResultProcessingBeforeConcurrentHandlingException() throws Exception {
281-
DeferredResult<Integer> deferredResult = new DeferredResult<Integer>();
282+
DeferredResult<Integer> deferredResult = new DeferredResult<>();
282283
Exception exception = new Exception();
283284

284285
DeferredResultProcessingInterceptor interceptor = mock(DeferredResultProcessingInterceptor.class);
@@ -303,7 +304,7 @@ public void startDeferredResultProcessingBeforeConcurrentHandlingException() thr
303304
@Test
304305
public void startDeferredResultProcessingPreProcessException() throws Exception {
305306

306-
DeferredResult<Integer> deferredResult = new DeferredResult<Integer>();
307+
DeferredResult<Integer> deferredResult = new DeferredResult<>();
307308
Exception exception = new Exception();
308309

309310
DeferredResultProcessingInterceptor interceptor = mock(DeferredResultProcessingInterceptor.class);
@@ -323,7 +324,7 @@ public void startDeferredResultProcessingPreProcessException() throws Exception
323324

324325
@Test
325326
public void startDeferredResultProcessingPostProcessException() throws Exception {
326-
DeferredResult<Integer> deferredResult = new DeferredResult<Integer>();
327+
DeferredResult<Integer> deferredResult = new DeferredResult<>();
327328
Exception exception = new Exception();
328329

329330
DeferredResultProcessingInterceptor interceptor = mock(DeferredResultProcessingInterceptor.class);

spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTimeoutTests.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 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.
@@ -28,12 +28,9 @@
2828
import org.springframework.mock.web.test.MockHttpServletResponse;
2929
import org.springframework.web.context.request.NativeWebRequest;
3030

31-
import static org.junit.Assert.assertEquals;
32-
import static org.junit.Assert.assertTrue;
33-
import static org.mockito.BDDMockito.given;
34-
import static org.mockito.BDDMockito.mock;
35-
import static org.mockito.BDDMockito.verify;
36-
import static org.springframework.web.context.request.async.CallableProcessingInterceptor.RESULT_NONE;
31+
import static org.junit.Assert.*;
32+
import static org.mockito.BDDMockito.*;
33+
import static org.springframework.web.context.request.async.CallableProcessingInterceptor.*;
3734

3835
/**
3936
* {@link WebAsyncManager} tests where container-triggered timeout/completion
@@ -53,8 +50,9 @@ public class WebAsyncManagerTimeoutTests {
5350

5451
private MockHttpServletResponse servletResponse;
5552

53+
5654
@Before
57-
public void setUp() {
55+
public void setup() {
5856
this.servletRequest = new MockHttpServletRequest("GET", "/test");
5957
this.servletRequest.setAsyncSupported(true);
6058
this.servletResponse = new MockHttpServletResponse();
@@ -67,9 +65,9 @@ public void setUp() {
6765
this.asyncManager.setAsyncWebRequest(this.asyncWebRequest);
6866
}
6967

68+
7069
@Test
7170
public void startCallableProcessingTimeoutAndComplete() throws Exception {
72-
7371
StubCallable callable = new StubCallable();
7472

7573
CallableProcessingInterceptor interceptor = mock(CallableProcessingInterceptor.class);
@@ -92,7 +90,7 @@ public void startCallableProcessingTimeoutAndComplete() throws Exception {
9290
public void startCallableProcessingTimeoutAndResumeThroughCallback() throws Exception {
9391

9492
StubCallable callable = new StubCallable();
95-
WebAsyncTask<Object> webAsyncTask = new WebAsyncTask<Object>(callable);
93+
WebAsyncTask<Object> webAsyncTask = new WebAsyncTask<>(callable);
9694
webAsyncTask.onTimeout(new Callable<Object>() {
9795
@Override
9896
public Object call() throws Exception {
@@ -153,7 +151,7 @@ public void startCallableProcessingAfterTimeoutException() throws Exception {
153151
@Test
154152
public void startDeferredResultProcessingTimeoutAndComplete() throws Exception {
155153

156-
DeferredResult<Integer> deferredResult = new DeferredResult<Integer>();
154+
DeferredResult<Integer> deferredResult = new DeferredResult<>();
157155

158156
DeferredResultProcessingInterceptor interceptor = mock(DeferredResultProcessingInterceptor.class);
159157
given(interceptor.handleTimeout(this.asyncWebRequest, deferredResult)).willReturn(true);
@@ -175,7 +173,7 @@ public void startDeferredResultProcessingTimeoutAndComplete() throws Exception {
175173
@Test
176174
public void startDeferredResultProcessingTimeoutAndResumeWithDefaultResult() throws Exception {
177175

178-
DeferredResult<Integer> deferredResult = new DeferredResult<Integer>(null, 23);
176+
DeferredResult<Integer> deferredResult = new DeferredResult<>(null, 23);
179177
this.asyncManager.startDeferredResultProcessing(deferredResult);
180178

181179
AsyncEvent event = null;
@@ -189,7 +187,7 @@ public void startDeferredResultProcessingTimeoutAndResumeWithDefaultResult() thr
189187
@Test
190188
public void startDeferredResultProcessingTimeoutAndResumeThroughCallback() throws Exception {
191189

192-
final DeferredResult<Integer> deferredResult = new DeferredResult<Integer>();
190+
final DeferredResult<Integer> deferredResult = new DeferredResult<>();
193191
deferredResult.onTimeout(new Runnable() {
194192
@Override
195193
public void run() {
@@ -210,7 +208,7 @@ public void run() {
210208
@Test
211209
public void startDeferredResultProcessingTimeoutAndResumeThroughInterceptor() throws Exception {
212210

213-
DeferredResult<Integer> deferredResult = new DeferredResult<Integer>();
211+
DeferredResult<Integer> deferredResult = new DeferredResult<>();
214212

215213
DeferredResultProcessingInterceptor interceptor = new DeferredResultProcessingInterceptorAdapter() {
216214
@Override
@@ -234,7 +232,7 @@ public <T> boolean handleTimeout(NativeWebRequest request, DeferredResult<T> res
234232
@Test
235233
public void startDeferredResultProcessingAfterTimeoutException() throws Exception {
236234

237-
DeferredResult<Integer> deferredResult = new DeferredResult<Integer>();
235+
DeferredResult<Integer> deferredResult = new DeferredResult<>();
238236
final Exception exception = new Exception();
239237

240238
DeferredResultProcessingInterceptor interceptor = new DeferredResultProcessingInterceptorAdapter() {

0 commit comments

Comments
 (0)