Skip to content

Commit 8ef557d

Browse files
committed
Merge branch '5.1.x'
2 parents 5e15bbf + b2c5659 commit 8ef557d

File tree

16 files changed

+87
-43
lines changed

16 files changed

+87
-43
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ext {
3939
junit5Version = "5.5.1"
4040
kotlinVersion = "1.3.41"
4141
log4jVersion = "2.12.0"
42-
nettyVersion = "4.1.37.Final"
42+
nettyVersion = "4.1.38.Final"
4343
reactorVersion = "Dysprosium-M3"
4444
rsocketVersion = "0.12.2-RC4"
4545
rxjavaVersion = "1.3.8"
@@ -149,7 +149,7 @@ configure(allprojects) { project ->
149149
}
150150

151151
checkstyle {
152-
toolVersion = "8.22"
152+
toolVersion = "8.23"
153153
configDir = rootProject.file("src/checkstyle")
154154
}
155155

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ public boolean equals(@Nullable Object other) {
430430

431431
@Override
432432
public int hashCode() {
433-
return 31 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.containingClass);
433+
return (31 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.containingClass));
434434
}
435435

436436

spring-context/src/main/java/org/springframework/validation/ObjectError.java

Lines changed: 2 additions & 2 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-2019 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.
@@ -144,7 +144,7 @@ public boolean equals(@Nullable Object other) {
144144

145145
@Override
146146
public int hashCode() {
147-
return super.hashCode() * 29 + getObjectName().hashCode();
147+
return (29 * super.hashCode() + getObjectName().hashCode());
148148
}
149149

150150
@Override

spring-core/src/main/java/org/springframework/core/MethodParameter.java

Lines changed: 10 additions & 4 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-2019 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 @@
3939
import org.springframework.lang.Nullable;
4040
import org.springframework.util.Assert;
4141
import org.springframework.util.ClassUtils;
42+
import org.springframework.util.ObjectUtils;
4243

4344
/**
4445
* Helper class that encapsulates the specification of a method parameter, i.e. a {@link Method}
@@ -61,14 +62,15 @@ public class MethodParameter {
6162

6263
private static final Annotation[] EMPTY_ANNOTATION_ARRAY = new Annotation[0];
6364

65+
6466
private final Executable executable;
6567

6668
private final int parameterIndex;
6769

6870
@Nullable
6971
private volatile Parameter parameter;
7072

71-
private int nestingLevel = 1;
73+
private int nestingLevel;
7274

7375
/** Map from Integer level to Integer type index. */
7476
@Nullable
@@ -662,12 +664,16 @@ public boolean equals(@Nullable Object other) {
662664
return false;
663665
}
664666
MethodParameter otherParam = (MethodParameter) other;
665-
return (this.parameterIndex == otherParam.parameterIndex && getExecutable().equals(otherParam.getExecutable()));
667+
return (this.containingClass == otherParam.containingClass &&
668+
ObjectUtils.nullSafeEquals(this.typeIndexesPerLevel, otherParam.typeIndexesPerLevel) &&
669+
this.nestingLevel == otherParam.nestingLevel &&
670+
this.parameterIndex == otherParam.parameterIndex &&
671+
this.executable.equals(otherParam.executable));
666672
}
667673

668674
@Override
669675
public int hashCode() {
670-
return (getExecutable().hashCode() * 31 + this.parameterIndex);
676+
return (31 * this.executable.hashCode() + this.parameterIndex);
671677
}
672678

673679
@Override

spring-core/src/test/java/org/springframework/core/MethodParameterTests.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.lang.annotation.Target;
2323
import java.lang.reflect.Constructor;
2424
import java.lang.reflect.Method;
25+
import java.util.ArrayList;
2526
import java.util.concurrent.Callable;
2627

2728
import org.junit.Before;
@@ -149,6 +150,44 @@ public void genericConstructorParameterInInnerClass() throws Exception {
149150
assertThat(methodParameter.getGenericParameterType()).isEqualTo(ResolvableType.forClassWithGenerics(Callable.class, Integer.class).getType());
150151
}
151152

153+
@Test
154+
public void multipleResolveParameterTypeCalls() throws Exception {
155+
Method method = ArrayList.class.getMethod("get", int.class);
156+
MethodParameter methodParameter = MethodParameter.forExecutable(method, -1);
157+
assertEquals(Object.class, methodParameter.getParameterType());
158+
GenericTypeResolver.resolveParameterType(methodParameter, StringList.class);
159+
assertEquals(String.class, methodParameter.getParameterType());
160+
GenericTypeResolver.resolveParameterType(methodParameter, IntegerList.class);
161+
assertEquals(Integer.class, methodParameter.getParameterType());
162+
}
163+
164+
@Test
165+
public void equalsAndHashCodeConsidersContainingClass() throws Exception {
166+
Method method = ArrayList.class.getMethod("get", int.class);
167+
MethodParameter m1 = MethodParameter.forExecutable(method, -1);
168+
MethodParameter m2 = MethodParameter.forExecutable(method, -1);
169+
MethodParameter m3 = MethodParameter.forExecutable(method, -1).nested();
170+
assertEquals(m1, m2);
171+
assertNotEquals(m1, m3);
172+
assertEquals(m1.hashCode(), m2.hashCode());
173+
}
174+
175+
@Test
176+
public void equalsAndHashCodeConsidersNesting() throws Exception {
177+
Method method = ArrayList.class.getMethod("get", int.class);
178+
MethodParameter m1 = MethodParameter.forExecutable(method, -1);
179+
GenericTypeResolver.resolveParameterType(m1, StringList.class);
180+
MethodParameter m2 = MethodParameter.forExecutable(method, -1);
181+
GenericTypeResolver.resolveParameterType(m2, StringList.class);
182+
MethodParameter m3 = MethodParameter.forExecutable(method, -1);
183+
GenericTypeResolver.resolveParameterType(m3, IntegerList.class);
184+
MethodParameter m4 = MethodParameter.forExecutable(method, -1);
185+
assertEquals(m1, m2);
186+
assertNotEquals(m1, m3);
187+
assertNotEquals(m1, m4);
188+
assertEquals(m1.hashCode(), m2.hashCode());
189+
}
190+
152191

153192
public int method(String p1, long p2) {
154193
return 42;
@@ -173,4 +212,12 @@ public InnerClass(@Param String s, Callable<Integer> i) {
173212
private @interface Param {
174213
}
175214

215+
@SuppressWarnings("serial")
216+
private static class StringList extends ArrayList<String> {
217+
}
218+
219+
@SuppressWarnings("serial")
220+
private static class IntegerList extends ArrayList<Integer> {
221+
}
222+
176223
}

spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ public boolean equals(@Nullable Object other) {
591591

592592
@Override
593593
public int hashCode() {
594-
return 31 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.selector);
594+
return (31 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.selector));
595595
}
596596

597597
@Override

spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/HandlerMethodArgumentResolverComposite.java

Lines changed: 3 additions & 4 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-2019 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,9 +110,8 @@ public boolean supportsParameter(MethodParameter parameter) {
110110
public Object resolveArgument(MethodParameter parameter, Message<?> message) throws Exception {
111111
HandlerMethodArgumentResolver resolver = getArgumentResolver(parameter);
112112
if (resolver == null) {
113-
throw new IllegalStateException(
114-
"Unsupported parameter type [" + parameter.getParameterType().getName() + "]." +
115-
" supportsParameter should be called first.");
113+
throw new IllegalArgumentException("Unsupported parameter type [" +
114+
parameter.getParameterType().getName() + "]. supportsParameter should be called first.");
116115
}
117116
return resolver.resolveArgument(parameter, message);
118117
}

spring-test/src/main/java/org/springframework/test/context/web/WebMergedContextConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -178,7 +178,7 @@ public boolean equals(@Nullable Object other) {
178178
*/
179179
@Override
180180
public int hashCode() {
181-
return super.hashCode() * 31 + this.resourceBasePath.hashCode();
181+
return (31 * super.hashCode() + this.resourceBasePath.hashCode());
182182
}
183183

184184
/**

spring-web/src/main/java/org/springframework/http/ResponseEntity.java

Lines changed: 2 additions & 2 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-2019 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.
@@ -169,7 +169,7 @@ public boolean equals(@Nullable Object other) {
169169

170170
@Override
171171
public int hashCode() {
172-
return (super.hashCode() * 29 + ObjectUtils.nullSafeHashCode(this.status));
172+
return (29 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.status));
173173
}
174174

175175
@Override

spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public boolean setStatusCode(@Nullable HttpStatus status) {
108108
@Override
109109
@Nullable
110110
public HttpStatus getStatusCode() {
111-
return this.statusCode != null ? HttpStatus.resolve(this.statusCode) : null;
111+
return (this.statusCode != null ? HttpStatus.resolve(this.statusCode) : null);
112112
}
113113

114114
/**

0 commit comments

Comments
 (0)