Skip to content

Commit 77c6f16

Browse files
committed
Merge branch '6.1.x'
# Conflicts: # spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java # spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverTests.java # spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverTests.java
2 parents 2d33aac + 39cd316 commit 77c6f16

File tree

7 files changed

+31
-38
lines changed

7 files changed

+31
-38
lines changed

spring-aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa
7575

7676
private static final String COROUTINES_FLOW_CLASS_NAME = "kotlinx.coroutines.flow.Flow";
7777

78-
private static final boolean coroutinesReactorPresent = ClassUtils.isPresent("kotlinx.coroutines.reactor.MonoKt",
79-
JdkDynamicAopProxy.class.getClassLoader());;
78+
private static final boolean coroutinesReactorPresent = ClassUtils.isPresent(
79+
"kotlinx.coroutines.reactor.MonoKt", JdkDynamicAopProxy.class.getClassLoader());
8080

8181
/** We use a static Log to avoid serialization issues. */
8282
private static final Log logger = LogFactory.getLog(JdkDynamicAopProxy.class);

spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@
6565
*/
6666
public abstract class AopUtils {
6767

68-
private static final boolean coroutinesReactorPresent = ClassUtils.isPresent("kotlinx.coroutines.reactor.MonoKt",
69-
AopUtils.class.getClassLoader());;
68+
private static final boolean coroutinesReactorPresent = ClassUtils.isPresent(
69+
"kotlinx.coroutines.reactor.MonoKt", AopUtils.class.getClassLoader());
70+
7071

7172
/**
7273
* Check whether the given object is a JDK dynamic proxy or a CGLIB proxy.
@@ -353,8 +354,8 @@ public static Object invokeJoinpointUsingReflection(@Nullable Object target, Met
353354
// Use reflection to invoke the method.
354355
try {
355356
ReflectionUtils.makeAccessible(method);
356-
return coroutinesReactorPresent && KotlinDetector.isSuspendingFunction(method) ?
357-
KotlinDelegate.invokeSuspendingFunction(method, target, args) : method.invoke(target, args);
357+
return (coroutinesReactorPresent && KotlinDetector.isSuspendingFunction(method) ?
358+
KotlinDelegate.invokeSuspendingFunction(method, target, args) : method.invoke(target, args));
358359
}
359360
catch (InvocationTargetException ex) {
360361
// Invoked method threw a checked exception.

spring-context/src/main/java/org/springframework/context/aot/KotlinReflectionBeanRegistrationAotProcessor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
*/
3636
class KotlinReflectionBeanRegistrationAotProcessor implements BeanRegistrationAotProcessor {
3737

38-
@Nullable
3938
@Override
39+
@Nullable
4040
public BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) {
4141
Class<?> beanClass = registeredBean.getBeanClass();
4242
if (KotlinDetector.isKotlinType(beanClass)) {
@@ -45,6 +45,7 @@ public BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registe
4545
return null;
4646
}
4747

48+
4849
private static class AotContribution implements BeanRegistrationAotContribution {
4950

5051
private final Class<?> beanClass;

spring-web/src/test/java/org/springframework/http/server/ServletServerHttpRequestTests.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ void getHeaders() {
124124
assertThat(headers).as("No HttpHeaders returned").isNotNull();
125125
assertThat(headers.containsKey(headerName)).as("Invalid headers returned").isTrue();
126126
List<String> headerValues = headers.get(headerName);
127+
assertThat(headerValues).as("No header values returned").isNotNull();
127128
assertThat(headerValues.size()).as("Invalid header values returned").isEqualTo(2);
128129
assertThat(headerValues.contains(headerValue1)).as("Invalid header values returned").isTrue();
129130
assertThat(headerValues.contains(headerValue2)).as("Invalid header values returned").isTrue();
@@ -150,7 +151,7 @@ void getHeadersWithEmptyContentTypeAndEncoding() {
150151
assertThat(headers.getContentType()).isNull();
151152
}
152153

153-
@Test // gh-27957
154+
@Test // gh-27957
154155
void getHeadersWithWildcardContentType() {
155156
mockRequest.setContentType("*/*");
156157
mockRequest.removeHeader("Content-Type");
@@ -166,7 +167,7 @@ void getBody() throws IOException {
166167
assertThat(result).as("Invalid content returned").isEqualTo(content);
167168
}
168169

169-
@Test // gh-13318
170+
@Test // gh-13318
170171
void getFormBody() throws IOException {
171172
mockRequest.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
172173
mockRequest.setMethod("POST");
@@ -189,7 +190,7 @@ void getEmptyFormBody() throws IOException {
189190
assertThat(result).as("Invalid content returned").isEqualTo(content);
190191
}
191192

192-
@Test // gh-31327
193+
@Test // gh-31327
193194
void getFormBodyWhenQueryParamsAlsoPresent() throws IOException {
194195
mockRequest.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
195196
mockRequest.setMethod("POST");
@@ -203,7 +204,7 @@ void getFormBodyWhenQueryParamsAlsoPresent() throws IOException {
203204
assertThat(result).as("Invalid content returned").isEqualTo(content);
204205
}
205206

206-
@Test // gh-32471
207+
@Test // gh-32471
207208
void getFormBodyWhenNotEncodedCharactersPresent() throws IOException {
208209
mockRequest.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
209210
mockRequest.setMethod("POST");

spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverTests.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ void resolveStringArray() throws Exception {
186186
assertThat(result).asInstanceOf(array(String[].class)).containsExactly(expected);
187187
}
188188

189-
@Test // gh-32577
189+
@Test // gh-32577
190190
void resolveStringArrayWithEmptyArraySuffix() throws Exception {
191191
String[] expected = new String[] {"foo", "bar"};
192192
request.addParameter("name[]", expected[0]);
@@ -221,7 +221,6 @@ void resolveMultipartFileList() throws Exception {
221221

222222
MethodParameter param = this.testMethod.annotPresent(RequestParam.class).arg(List.class, MultipartFile.class);
223223
Object result = resolver.resolveArgument(param, null, webRequest, null);
224-
225224
assertThat(result).asInstanceOf(LIST).containsExactly(expected1, expected2);
226225
}
227226

@@ -248,7 +247,6 @@ void resolveMultipartFileArray() throws Exception {
248247

249248
MethodParameter param = this.testMethod.annotPresent(RequestParam.class).arg(MultipartFile[].class);
250249
Object result = resolver.resolveArgument(param, null, webRequest, null);
251-
252250
assertThat(result).asInstanceOf(array(MultipartFile[].class)).containsExactly(expected1, expected2);
253251
}
254252

@@ -274,7 +272,6 @@ void resolvePart() throws Exception {
274272

275273
MethodParameter param = this.testMethod.annotPresent(RequestParam.class).arg(Part.class);
276274
Object result = resolver.resolveArgument(param, null, webRequest, null);
277-
278275
assertThat(result).asInstanceOf(type(Part.class)).isEqualTo(expected);
279276
}
280277

@@ -292,7 +289,6 @@ void resolvePartList() throws Exception {
292289

293290
MethodParameter param = this.testMethod.annotPresent(RequestParam.class).arg(List.class, Part.class);
294291
Object result = resolver.resolveArgument(param, null, webRequest, null);
295-
296292
assertThat(result).asInstanceOf(LIST).containsExactly(expected1, expected2);
297293
}
298294

@@ -323,7 +319,6 @@ void resolvePartArray() throws Exception {
323319

324320
MethodParameter param = this.testMethod.annotPresent(RequestParam.class).arg(Part[].class);
325321
Object result = resolver.resolveArgument(param, null, webRequest, null);
326-
327322
assertThat(result).asInstanceOf(array(Part[].class)).containsExactly(expected1, expected2);
328323
}
329324

@@ -442,7 +437,6 @@ public void missingRequestParamEmptyValueConvertedToNull() throws Exception {
442437

443438
WebDataBinderFactory binderFactory = mock();
444439
given(binderFactory.createBinder(webRequest, null, "stringNotAnnot")).willReturn(binder);
445-
446440
request.addParameter("stringNotAnnot", "");
447441

448442
MethodParameter param = this.testMethod.annotNotPresent(RequestParam.class).arg(String.class);
@@ -456,7 +450,6 @@ public void missingRequestParamAfterConversionWithDefaultValue() throws Exceptio
456450

457451
WebDataBinderFactory binderFactory = mock();
458452
given(binderFactory.createBinder(webRequest, null, "booleanParam")).willReturn(binder);
459-
460453
request.addParameter("booleanParam", " ");
461454

462455
MethodParameter param = this.testMethod.annotPresent(RequestParam.class).arg(Boolean.class);
@@ -471,22 +464,20 @@ void missingRequestParamEmptyValueNotRequired() throws Exception {
471464

472465
WebDataBinderFactory binderFactory = mock();
473466
given(binderFactory.createBinder(webRequest, null, "name")).willReturn(binder);
474-
475467
request.addParameter("name", "");
476468

477469
MethodParameter param = this.testMethod.annot(requestParam().notRequired()).arg(String.class);
478470
Object arg = resolver.resolveArgument(param, null, webRequest, binderFactory);
479471
assertThat(arg).isNull();
480472
}
481473

482-
@Test // gh-29550
474+
@Test // gh-29550
483475
public void missingRequestParamEmptyValueNotRequiredWithDefaultValue() throws Exception {
484476
WebDataBinder binder = new WebRequestDataBinder(null);
485477
binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
486478

487479
WebDataBinderFactory binderFactory = mock();
488480
given(binderFactory.createBinder(webRequest, null, "name")).willReturn(binder);
489-
490481
request.addParameter("name", " ");
491482

492483
MethodParameter param = this.testMethod.annot(requestParam().notRequired("bar")).arg(String.class);
@@ -499,7 +490,6 @@ void resolveSimpleTypeParam() throws Exception {
499490
request.setParameter("stringNotAnnot", "plainValue");
500491
MethodParameter param = this.testMethod.annotNotPresent(RequestParam.class).arg(String.class);
501492
Object result = resolver.resolveArgument(param, null, webRequest, null);
502-
503493
assertThat(result).isEqualTo("plainValue");
504494
}
505495

@@ -646,7 +636,6 @@ void resolveOptionalMultipartFile() throws Exception {
646636

647637
MethodParameter param = this.testMethod.annotPresent(RequestParam.class).arg(Optional.class, MultipartFile.class);
648638
Object result = resolver.resolveArgument(param, null, webRequest, binderFactory);
649-
650639
assertThat(result).asInstanceOf(optional(MultipartFile.class)).contains(expected);
651640
}
652641

spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerAdviceTests.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ private void testException(Throwable exception, String threadName, String expect
188188
TestController controller = context.getBean(TestController.class);
189189
controller.setException(exception);
190190

191-
Object actual = handle(adapter, controller, this.postExchange, Duration.ofMillis(100)
192-
, "threadWithArg", String.class).getReturnValue();
191+
Object actual = handle(adapter, controller, this.postExchange, Duration.ofMillis(1000),
192+
"threadWithArg", String.class).getReturnValue();
193193
assertThat(actual).isEqualTo(expected);
194194
}
195195

@@ -242,14 +242,14 @@ public SecondControllerAdvice anotherTestExceptionResolver() {
242242
}
243243
}
244244

245+
245246
@Controller
246247
static class TestController {
247248

248249
private Validator validator;
249250

250251
private Throwable exception;
251252

252-
253253
void setValidator(Validator validator) {
254254
this.validator = validator;
255255
}
@@ -258,7 +258,6 @@ void setException(Throwable exception) {
258258
this.exception = exception;
259259
}
260260

261-
262261
@InitBinder
263262
public void initDataBinder(WebDataBinder dataBinder) {
264263
if (this.validator != null) {
@@ -291,6 +290,7 @@ public String thread() throws Throwable {
291290
}
292291
}
293292

293+
294294
@ControllerAdvice
295295
@Order(1)
296296
static class OneControllerAdvice {
@@ -323,6 +323,7 @@ public String handleAssertionError(Error err) {
323323
}
324324
}
325325

326+
326327
@ControllerAdvice
327328
@Order(2)
328329
static class SecondControllerAdvice {

spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverTests.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.web.reactive.result.method.annotation;
1818

19-
2019
import java.time.Duration;
2120
import java.util.Map;
2221
import java.util.Optional;
@@ -29,6 +28,7 @@
2928
import org.springframework.core.MethodParameter;
3029
import org.springframework.core.ReactiveAdapterRegistry;
3130
import org.springframework.format.support.DefaultFormattingConversionService;
31+
import org.springframework.lang.Nullable;
3232
import org.springframework.web.bind.annotation.RequestParam;
3333
import org.springframework.web.bind.support.ConfigurableWebBindingInitializer;
3434
import org.springframework.web.reactive.BindingContext;
@@ -105,12 +105,12 @@ void doesNotSupportParameterWithDefaultResolutionTurnedOff() {
105105

106106
@Test
107107
void doesNotSupportReactiveWrapper() {
108-
assertThatIllegalStateException().isThrownBy(() ->
109-
this.resolver.supportsParameter(this.testMethod.annot(requestParam()).arg(Mono.class, String.class)))
110-
.withMessageStartingWith("RequestParamMethodArgumentResolver does not support reactive type wrapper");
111-
assertThatIllegalStateException().isThrownBy(() ->
112-
this.resolver.supportsParameter(this.testMethod.annotNotPresent(RequestParam.class).arg(Mono.class, String.class)))
113-
.withMessageStartingWith("RequestParamMethodArgumentResolver does not support reactive type wrapper");
108+
assertThatIllegalStateException()
109+
.isThrownBy(() -> this.resolver.supportsParameter(this.testMethod.annot(requestParam()).arg(Mono.class, String.class)))
110+
.withMessageStartingWith("RequestParamMethodArgumentResolver does not support reactive type wrapper");
111+
assertThatIllegalStateException()
112+
.isThrownBy(() -> this.resolver.supportsParameter(this.testMethod.annotNotPresent(RequestParam.class).arg(Mono.class, String.class)))
113+
.withMessageStartingWith("RequestParamMethodArgumentResolver does not support reactive type wrapper");
114114
}
115115

116116
@Test
@@ -128,7 +128,7 @@ void resolveStringArray() {
128128
assertThat(result).asInstanceOf(array(String[].class)).containsExactly("foo", "bar");
129129
}
130130

131-
@Test // gh-32577
131+
@Test // gh-32577
132132
void resolveStringArrayWithEmptyArraySuffix() {
133133
MethodParameter param = this.testMethod.annotPresent(RequestParam.class).arg(String[].class);
134134
MockServerHttpRequest request = MockServerHttpRequest.get("/path?name[]=foo&name[]=bar").build();
@@ -142,7 +142,7 @@ void resolveDefaultValue() {
142142
assertThat(resolve(param, MockServerWebExchange.from(MockServerHttpRequest.get("/")))).isEqualTo("bar");
143143
}
144144

145-
@Test // SPR-17050
145+
@Test // SPR-17050
146146
public void resolveAndConvertNullValue() {
147147
MethodParameter param = this.testMethod
148148
.annot(requestParam().notRequired())
@@ -152,7 +152,6 @@ public void resolveAndConvertNullValue() {
152152

153153
@Test
154154
void missingRequestParam() {
155-
156155
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/"));
157156
MethodParameter param = this.testMethod.annotPresent(RequestParam.class).arg(String[].class);
158157
Mono<Object> mono = this.resolver.resolveArgument(param, this.bindContext, exchange);
@@ -214,6 +213,7 @@ void resolveOptionalParamValue() {
214213
}
215214

216215

216+
@Nullable
217217
private Object resolve(MethodParameter parameter, ServerWebExchange exchange) {
218218
return this.resolver.resolveArgument(parameter, this.bindContext, exchange).block(Duration.ZERO);
219219
}

0 commit comments

Comments
 (0)