Skip to content

Commit 4b3e861

Browse files
committed
Polishing
1 parent 50d597e commit 4b3e861

File tree

4 files changed

+32
-34
lines changed

4 files changed

+32
-34
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/config/ConstructorArgumentValues.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 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.
@@ -351,7 +351,9 @@ public ValueHolder getArgumentValue(int index, Class<?> requiredType, String req
351351
* @return the ValueHolder for the argument, or {@code null} if none set
352352
*/
353353
@Nullable
354-
public ValueHolder getArgumentValue(int index, @Nullable Class<?> requiredType, @Nullable String requiredName, @Nullable Set<ValueHolder> usedValueHolders) {
354+
public ValueHolder getArgumentValue(int index, @Nullable Class<?> requiredType,
355+
@Nullable String requiredName, @Nullable Set<ValueHolder> usedValueHolders) {
356+
355357
Assert.isTrue(index >= 0, "Index must not be negative");
356358
ValueHolder valueHolder = getIndexedArgumentValue(index, requiredType, requiredName);
357359
if (valueHolder == null) {

spring-beans/src/test/java/org/springframework/beans/BeanWrapperAutoGrowingTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class BeanWrapperAutoGrowingTests {
3838

3939

4040
@BeforeEach
41-
public void setUp() {
41+
public void setup() {
4242
wrapper.setAutoGrowNestedPaths(true);
4343
}
4444

spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 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,7 +16,6 @@
1616

1717
package org.springframework.beans;
1818

19-
import java.net.MalformedURLException;
2019
import java.util.ArrayList;
2120
import java.util.Arrays;
2221
import java.util.Collection;
@@ -86,7 +85,7 @@ public void testGenericSetWithConversionFailure() {
8685
}
8786

8887
@Test
89-
public void testGenericList() throws MalformedURLException {
88+
public void testGenericList() throws Exception {
9089
GenericBean<?> gb = new GenericBean<>();
9190
BeanWrapper bw = new BeanWrapperImpl(gb);
9291
List<String> input = new ArrayList<>();
@@ -98,7 +97,7 @@ public void testGenericList() throws MalformedURLException {
9897
}
9998

10099
@Test
101-
public void testGenericListElement() throws MalformedURLException {
100+
public void testGenericListElement() throws Exception {
102101
GenericBean<?> gb = new GenericBean<>();
103102
gb.setResourceList(new ArrayList<>());
104103
BeanWrapper bw = new BeanWrapperImpl(gb);
@@ -195,7 +194,7 @@ public void testGenericMapFromProperties() {
195194
}
196195

197196
@Test
198-
public void testGenericListOfLists() throws MalformedURLException {
197+
public void testGenericListOfLists() {
199198
GenericBean<String> gb = new GenericBean<>();
200199
List<List<Integer>> list = new LinkedList<>();
201200
list.add(new LinkedList<>());
@@ -207,7 +206,7 @@ public void testGenericListOfLists() throws MalformedURLException {
207206
}
208207

209208
@Test
210-
public void testGenericListOfListsWithElementConversion() throws MalformedURLException {
209+
public void testGenericListOfListsWithElementConversion() {
211210
GenericBean<String> gb = new GenericBean<>();
212211
List<List<Integer>> list = new LinkedList<>();
213212
list.add(new LinkedList<>());
@@ -219,7 +218,7 @@ public void testGenericListOfListsWithElementConversion() throws MalformedURLExc
219218
}
220219

221220
@Test
222-
public void testGenericListOfArrays() throws MalformedURLException {
221+
public void testGenericListOfArrays() {
223222
GenericBean<String> gb = new GenericBean<>();
224223
ArrayList<String[]> list = new ArrayList<>();
225224
list.add(new String[] {"str1", "str2"});
@@ -231,7 +230,7 @@ public void testGenericListOfArrays() throws MalformedURLException {
231230
}
232231

233232
@Test
234-
public void testGenericListOfArraysWithElementConversion() throws MalformedURLException {
233+
public void testGenericListOfArraysWithElementConversion() {
235234
GenericBean<String> gb = new GenericBean<>();
236235
ArrayList<String[]> list = new ArrayList<>();
237236
list.add(new String[] {"str1", "str2"});
@@ -244,7 +243,7 @@ public void testGenericListOfArraysWithElementConversion() throws MalformedURLEx
244243
}
245244

246245
@Test
247-
public void testGenericListOfMaps() throws MalformedURLException {
246+
public void testGenericListOfMaps() {
248247
GenericBean<String> gb = new GenericBean<>();
249248
List<Map<Integer, Long>> list = new LinkedList<>();
250249
list.add(new HashMap<>());
@@ -256,7 +255,7 @@ public void testGenericListOfMaps() throws MalformedURLException {
256255
}
257256

258257
@Test
259-
public void testGenericListOfMapsWithElementConversion() throws MalformedURLException {
258+
public void testGenericListOfMapsWithElementConversion() {
260259
GenericBean<String> gb = new GenericBean<>();
261260
List<Map<Integer, Long>> list = new LinkedList<>();
262261
list.add(new HashMap<>());
@@ -268,7 +267,7 @@ public void testGenericListOfMapsWithElementConversion() throws MalformedURLExce
268267
}
269268

270269
@Test
271-
public void testGenericMapOfMaps() throws MalformedURLException {
270+
public void testGenericMapOfMaps() {
272271
GenericBean<String> gb = new GenericBean<>();
273272
Map<String, Map<Integer, Long>> map = new HashMap<>();
274273
map.put("mykey", new HashMap<>());
@@ -280,7 +279,7 @@ public void testGenericMapOfMaps() throws MalformedURLException {
280279
}
281280

282281
@Test
283-
public void testGenericMapOfMapsWithElementConversion() throws MalformedURLException {
282+
public void testGenericMapOfMapsWithElementConversion() {
284283
GenericBean<String> gb = new GenericBean<>();
285284
Map<String, Map<Integer, Long>> map = new HashMap<>();
286285
map.put("mykey", new HashMap<>());
@@ -292,7 +291,7 @@ public void testGenericMapOfMapsWithElementConversion() throws MalformedURLExcep
292291
}
293292

294293
@Test
295-
public void testGenericMapOfLists() throws MalformedURLException {
294+
public void testGenericMapOfLists() {
296295
GenericBean<String> gb = new GenericBean<>();
297296
Map<Integer, List<Integer>> map = new HashMap<>();
298297
map.put(1, new LinkedList<>());
@@ -304,7 +303,7 @@ public void testGenericMapOfLists() throws MalformedURLException {
304303
}
305304

306305
@Test
307-
public void testGenericMapOfListsWithElementConversion() throws MalformedURLException {
306+
public void testGenericMapOfListsWithElementConversion() {
308307
GenericBean<String> gb = new GenericBean<>();
309308
Map<Integer, List<Integer>> map = new HashMap<>();
310309
map.put(1, new LinkedList<>());
@@ -316,7 +315,7 @@ public void testGenericMapOfListsWithElementConversion() throws MalformedURLExce
316315
}
317316

318317
@Test
319-
public void testGenericTypeNestingMapOfInteger() throws Exception {
318+
public void testGenericTypeNestingMapOfInteger() {
320319
Map<String, String> map = new HashMap<>();
321320
map.put("testKey", "100");
322321

@@ -330,7 +329,7 @@ public void testGenericTypeNestingMapOfInteger() throws Exception {
330329
}
331330

332331
@Test
333-
public void testGenericTypeNestingMapOfListOfInteger() throws Exception {
332+
public void testGenericTypeNestingMapOfListOfInteger() {
334333
Map<String, List<String>> map = new HashMap<>();
335334
List<String> list = Arrays.asList(new String[] {"1", "2", "3"});
336335
map.put("testKey", list);
@@ -340,13 +339,12 @@ public void testGenericTypeNestingMapOfListOfInteger() throws Exception {
340339
bw.setPropertyValue("mapOfListOfInteger", map);
341340

342341
Object obj = gb.getMapOfListOfInteger().get("testKey").get(0);
343-
boolean condition = obj instanceof Integer;
344-
assertThat(condition).isTrue();
342+
assertThat(obj instanceof Integer).isTrue();
345343
assertThat(((Integer) obj).intValue()).isEqualTo(1);
346344
}
347345

348346
@Test
349-
public void testGenericTypeNestingListOfMapOfInteger() throws Exception {
347+
public void testGenericTypeNestingListOfMapOfInteger() {
350348
List<Map<String, String>> list = new LinkedList<>();
351349
Map<String, String> map = new HashMap<>();
352350
map.put("testKey", "5");
@@ -357,13 +355,12 @@ public void testGenericTypeNestingListOfMapOfInteger() throws Exception {
357355
bw.setPropertyValue("listOfMapOfInteger", list);
358356

359357
Object obj = gb.getListOfMapOfInteger().get(0).get("testKey");
360-
boolean condition = obj instanceof Integer;
361-
assertThat(condition).isTrue();
358+
assertThat(obj instanceof Integer).isTrue();
362359
assertThat(((Integer) obj).intValue()).isEqualTo(5);
363360
}
364361

365362
@Test
366-
public void testGenericTypeNestingMapOfListOfListOfInteger() throws Exception {
363+
public void testGenericTypeNestingMapOfListOfListOfInteger() {
367364
Map<String, List<List<String>>> map = new HashMap<>();
368365
List<String> list = Arrays.asList(new String[] {"1", "2", "3"});
369366
map.put("testKey", Collections.singletonList(list));
@@ -373,8 +370,7 @@ public void testGenericTypeNestingMapOfListOfListOfInteger() throws Exception {
373370
bw.setPropertyValue("mapOfListOfListOfInteger", map);
374371

375372
Object obj = gb.getMapOfListOfListOfInteger().get("testKey").get(0).get(0);
376-
boolean condition = obj instanceof Integer;
377-
assertThat(condition).isTrue();
373+
assertThat(obj instanceof Integer).isTrue();
378374
assertThat(((Integer) obj).intValue()).isEqualTo(1);
379375
}
380376

@@ -465,7 +461,7 @@ public void testComplexDerivedIndexedMapEntryWithCollectionConversion() {
465461
}
466462

467463
@Test
468-
public void testGenericallyTypedIntegerBean() throws Exception {
464+
public void testGenericallyTypedIntegerBean() {
469465
GenericIntegerBean gb = new GenericIntegerBean();
470466
BeanWrapper bw = new BeanWrapperImpl(gb);
471467
bw.setPropertyValue("genericProperty", "10");
@@ -476,7 +472,7 @@ public void testGenericallyTypedIntegerBean() throws Exception {
476472
}
477473

478474
@Test
479-
public void testGenericallyTypedSetOfIntegerBean() throws Exception {
475+
public void testGenericallyTypedSetOfIntegerBean() {
480476
GenericSetOfIntegerBean gb = new GenericSetOfIntegerBean();
481477
BeanWrapper bw = new BeanWrapperImpl(gb);
482478
bw.setPropertyValue("genericProperty", "10");

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2021 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.
@@ -221,7 +221,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
221221
private boolean webApplicationContextInjected = false;
222222

223223
/** Flag used to detect whether onRefresh has already been called. */
224-
private volatile boolean refreshEventReceived = false;
224+
private volatile boolean refreshEventReceived;
225225

226226
/** Monitor for synchronized onRefresh execution. */
227227
private final Object onRefreshMonitor = new Object();
@@ -1084,8 +1084,8 @@ private void logResult(HttpServletRequest request, HttpServletResponse response,
10841084
return;
10851085
}
10861086

1087-
String dispatchType = request.getDispatcherType().name();
1088-
boolean initialDispatch = request.getDispatcherType().equals(DispatcherType.REQUEST);
1087+
DispatcherType dispatchType = request.getDispatcherType();
1088+
boolean initialDispatch = (dispatchType == DispatcherType.REQUEST);
10891089

10901090
if (failureCause != null) {
10911091
if (!initialDispatch) {
@@ -1109,7 +1109,7 @@ else if (logger.isTraceEnabled()) {
11091109
}
11101110

11111111
int status = response.getStatus();
1112-
String headers = ""; // nothing below trace
1112+
String headers = ""; // nothing below trace
11131113

11141114
if (logger.isTraceEnabled()) {
11151115
Collection<String> names = response.getHeaderNames();

0 commit comments

Comments
 (0)