Browse Source

Polishing

pull/28694/head
Juergen Hoeller 5 years ago
parent
commit
4b3e8619ec
  1. 6
      spring-beans/src/main/java/org/springframework/beans/factory/config/ConstructorArgumentValues.java
  2. 2
      spring-beans/src/test/java/org/springframework/beans/BeanWrapperAutoGrowingTests.java
  3. 48
      spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java
  4. 10
      spring-webmvc/src/main/java/org/springframework/web/servlet/FrameworkServlet.java

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -351,7 +351,9 @@ public class ConstructorArgumentValues { @@ -351,7 +351,9 @@ public class ConstructorArgumentValues {
* @return the ValueHolder for the argument, or {@code null} if none set
*/
@Nullable
public ValueHolder getArgumentValue(int index, @Nullable Class<?> requiredType, @Nullable String requiredName, @Nullable Set<ValueHolder> usedValueHolders) {
public ValueHolder getArgumentValue(int index, @Nullable Class<?> requiredType,
@Nullable String requiredName, @Nullable Set<ValueHolder> usedValueHolders) {
Assert.isTrue(index >= 0, "Index must not be negative");
ValueHolder valueHolder = getIndexedArgumentValue(index, requiredType, requiredName);
if (valueHolder == null) {

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

@ -38,7 +38,7 @@ public class BeanWrapperAutoGrowingTests { @@ -38,7 +38,7 @@ public class BeanWrapperAutoGrowingTests {
@BeforeEach
public void setUp() {
public void setup() {
wrapper.setAutoGrowNestedPaths(true);
}

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@ @@ -16,7 +16,6 @@
package org.springframework.beans;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -86,7 +85,7 @@ public class BeanWrapperGenericsTests { @@ -86,7 +85,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericList() throws MalformedURLException {
public void testGenericList() throws Exception {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
List<String> input = new ArrayList<>();
@ -98,7 +97,7 @@ public class BeanWrapperGenericsTests { @@ -98,7 +97,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericListElement() throws MalformedURLException {
public void testGenericListElement() throws Exception {
GenericBean<?> gb = new GenericBean<>();
gb.setResourceList(new ArrayList<>());
BeanWrapper bw = new BeanWrapperImpl(gb);
@ -195,7 +194,7 @@ public class BeanWrapperGenericsTests { @@ -195,7 +194,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericListOfLists() throws MalformedURLException {
public void testGenericListOfLists() {
GenericBean<String> gb = new GenericBean<>();
List<List<Integer>> list = new LinkedList<>();
list.add(new LinkedList<>());
@ -207,7 +206,7 @@ public class BeanWrapperGenericsTests { @@ -207,7 +206,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericListOfListsWithElementConversion() throws MalformedURLException {
public void testGenericListOfListsWithElementConversion() {
GenericBean<String> gb = new GenericBean<>();
List<List<Integer>> list = new LinkedList<>();
list.add(new LinkedList<>());
@ -219,7 +218,7 @@ public class BeanWrapperGenericsTests { @@ -219,7 +218,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericListOfArrays() throws MalformedURLException {
public void testGenericListOfArrays() {
GenericBean<String> gb = new GenericBean<>();
ArrayList<String[]> list = new ArrayList<>();
list.add(new String[] {"str1", "str2"});
@ -231,7 +230,7 @@ public class BeanWrapperGenericsTests { @@ -231,7 +230,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericListOfArraysWithElementConversion() throws MalformedURLException {
public void testGenericListOfArraysWithElementConversion() {
GenericBean<String> gb = new GenericBean<>();
ArrayList<String[]> list = new ArrayList<>();
list.add(new String[] {"str1", "str2"});
@ -244,7 +243,7 @@ public class BeanWrapperGenericsTests { @@ -244,7 +243,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericListOfMaps() throws MalformedURLException {
public void testGenericListOfMaps() {
GenericBean<String> gb = new GenericBean<>();
List<Map<Integer, Long>> list = new LinkedList<>();
list.add(new HashMap<>());
@ -256,7 +255,7 @@ public class BeanWrapperGenericsTests { @@ -256,7 +255,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericListOfMapsWithElementConversion() throws MalformedURLException {
public void testGenericListOfMapsWithElementConversion() {
GenericBean<String> gb = new GenericBean<>();
List<Map<Integer, Long>> list = new LinkedList<>();
list.add(new HashMap<>());
@ -268,7 +267,7 @@ public class BeanWrapperGenericsTests { @@ -268,7 +267,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericMapOfMaps() throws MalformedURLException {
public void testGenericMapOfMaps() {
GenericBean<String> gb = new GenericBean<>();
Map<String, Map<Integer, Long>> map = new HashMap<>();
map.put("mykey", new HashMap<>());
@ -280,7 +279,7 @@ public class BeanWrapperGenericsTests { @@ -280,7 +279,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericMapOfMapsWithElementConversion() throws MalformedURLException {
public void testGenericMapOfMapsWithElementConversion() {
GenericBean<String> gb = new GenericBean<>();
Map<String, Map<Integer, Long>> map = new HashMap<>();
map.put("mykey", new HashMap<>());
@ -292,7 +291,7 @@ public class BeanWrapperGenericsTests { @@ -292,7 +291,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericMapOfLists() throws MalformedURLException {
public void testGenericMapOfLists() {
GenericBean<String> gb = new GenericBean<>();
Map<Integer, List<Integer>> map = new HashMap<>();
map.put(1, new LinkedList<>());
@ -304,7 +303,7 @@ public class BeanWrapperGenericsTests { @@ -304,7 +303,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericMapOfListsWithElementConversion() throws MalformedURLException {
public void testGenericMapOfListsWithElementConversion() {
GenericBean<String> gb = new GenericBean<>();
Map<Integer, List<Integer>> map = new HashMap<>();
map.put(1, new LinkedList<>());
@ -316,7 +315,7 @@ public class BeanWrapperGenericsTests { @@ -316,7 +315,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericTypeNestingMapOfInteger() throws Exception {
public void testGenericTypeNestingMapOfInteger() {
Map<String, String> map = new HashMap<>();
map.put("testKey", "100");
@ -330,7 +329,7 @@ public class BeanWrapperGenericsTests { @@ -330,7 +329,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericTypeNestingMapOfListOfInteger() throws Exception {
public void testGenericTypeNestingMapOfListOfInteger() {
Map<String, List<String>> map = new HashMap<>();
List<String> list = Arrays.asList(new String[] {"1", "2", "3"});
map.put("testKey", list);
@ -340,13 +339,12 @@ public class BeanWrapperGenericsTests { @@ -340,13 +339,12 @@ public class BeanWrapperGenericsTests {
bw.setPropertyValue("mapOfListOfInteger", map);
Object obj = gb.getMapOfListOfInteger().get("testKey").get(0);
boolean condition = obj instanceof Integer;
assertThat(condition).isTrue();
assertThat(obj instanceof Integer).isTrue();
assertThat(((Integer) obj).intValue()).isEqualTo(1);
}
@Test
public void testGenericTypeNestingListOfMapOfInteger() throws Exception {
public void testGenericTypeNestingListOfMapOfInteger() {
List<Map<String, String>> list = new LinkedList<>();
Map<String, String> map = new HashMap<>();
map.put("testKey", "5");
@ -357,13 +355,12 @@ public class BeanWrapperGenericsTests { @@ -357,13 +355,12 @@ public class BeanWrapperGenericsTests {
bw.setPropertyValue("listOfMapOfInteger", list);
Object obj = gb.getListOfMapOfInteger().get(0).get("testKey");
boolean condition = obj instanceof Integer;
assertThat(condition).isTrue();
assertThat(obj instanceof Integer).isTrue();
assertThat(((Integer) obj).intValue()).isEqualTo(5);
}
@Test
public void testGenericTypeNestingMapOfListOfListOfInteger() throws Exception {
public void testGenericTypeNestingMapOfListOfListOfInteger() {
Map<String, List<List<String>>> map = new HashMap<>();
List<String> list = Arrays.asList(new String[] {"1", "2", "3"});
map.put("testKey", Collections.singletonList(list));
@ -373,8 +370,7 @@ public class BeanWrapperGenericsTests { @@ -373,8 +370,7 @@ public class BeanWrapperGenericsTests {
bw.setPropertyValue("mapOfListOfListOfInteger", map);
Object obj = gb.getMapOfListOfListOfInteger().get("testKey").get(0).get(0);
boolean condition = obj instanceof Integer;
assertThat(condition).isTrue();
assertThat(obj instanceof Integer).isTrue();
assertThat(((Integer) obj).intValue()).isEqualTo(1);
}
@ -465,7 +461,7 @@ public class BeanWrapperGenericsTests { @@ -465,7 +461,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericallyTypedIntegerBean() throws Exception {
public void testGenericallyTypedIntegerBean() {
GenericIntegerBean gb = new GenericIntegerBean();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("genericProperty", "10");
@ -476,7 +472,7 @@ public class BeanWrapperGenericsTests { @@ -476,7 +472,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericallyTypedSetOfIntegerBean() throws Exception {
public void testGenericallyTypedSetOfIntegerBean() {
GenericSetOfIntegerBean gb = new GenericSetOfIntegerBean();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("genericProperty", "10");

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -221,7 +221,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic @@ -221,7 +221,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
private boolean webApplicationContextInjected = false;
/** Flag used to detect whether onRefresh has already been called. */
private volatile boolean refreshEventReceived = false;
private volatile boolean refreshEventReceived;
/** Monitor for synchronized onRefresh execution. */
private final Object onRefreshMonitor = new Object();
@ -1084,8 +1084,8 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic @@ -1084,8 +1084,8 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
return;
}
String dispatchType = request.getDispatcherType().name();
boolean initialDispatch = request.getDispatcherType().equals(DispatcherType.REQUEST);
DispatcherType dispatchType = request.getDispatcherType();
boolean initialDispatch = (dispatchType == DispatcherType.REQUEST);
if (failureCause != null) {
if (!initialDispatch) {
@ -1109,7 +1109,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic @@ -1109,7 +1109,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
}
int status = response.getStatus();
String headers = ""; // nothing below trace
String headers = ""; // nothing below trace
if (logger.isTraceEnabled()) {
Collection<String> names = response.getHeaderNames();

Loading…
Cancel
Save