Skip to content

Commit 8ab965c

Browse files
committed
Merge branch '6.1.x'
# Conflicts: # spring-web/src/main/java/org/springframework/web/method/annotation/AbstractNamedValueMethodArgumentResolver.java # spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractNamedValueArgumentResolver.java
2 parents 854f6ff + 87157d3 commit 8ab965c

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

spring-web/src/main/java/org/springframework/http/codec/ServerSentEvent.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2024 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.
@@ -104,13 +104,13 @@ public T data() {
104104

105105
@Override
106106
public String toString() {
107-
return ("ServerSentEvent [id = '" + this.id + "\', event='" + this.event + "\', retry=" +
107+
return ("ServerSentEvent [id = '" + this.id + "', event='" + this.event + "', retry=" +
108108
this.retry + ", comment='" + this.comment + "', data=" + this.data + ']');
109109
}
110110

111111

112112
/**
113-
* Return a builder for a {@code SseEvent}.
113+
* Return a builder for a {@code ServerSentEvent}.
114114
* @param <T> the type of data that this event contains
115115
* @return the builder
116116
*/
@@ -119,7 +119,7 @@ public static <T> Builder<T> builder() {
119119
}
120120

121121
/**
122-
* Return a builder for a {@code SseEvent}, populated with the given {@linkplain #data() data}.
122+
* Return a builder for a {@code ServerSentEvent}, populated with the given {@linkplain #data() data}.
123123
* @param <T> the type of data that this event contains
124124
* @return the builder
125125
*/
@@ -129,7 +129,7 @@ public static <T> Builder<T> builder(T data) {
129129

130130

131131
/**
132-
* A mutable builder for a {@code SseEvent}.
132+
* A mutable builder for a {@code ServerSentEvent}.
133133
*
134134
* @param <T> the type of data that this event contains
135135
*/

spring-web/src/main/java/org/springframework/web/method/annotation/AbstractNamedValueMethodArgumentResolver.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import org.springframework.core.KotlinDetector;
3636
import org.springframework.core.MethodParameter;
3737
import org.springframework.lang.Nullable;
38-
import org.springframework.util.Assert;
3938
import org.springframework.web.bind.ServletRequestBindingException;
4039
import org.springframework.web.bind.WebDataBinder;
4140
import org.springframework.web.bind.annotation.ValueConstants;
@@ -107,9 +106,9 @@ public final Object resolveArgument(MethodParameter parameter, @Nullable ModelAn
107106

108107
NamedValueInfo namedValueInfo = getNamedValueInfo(parameter);
109108
MethodParameter nestedParameter = parameter.nestedIfOptional();
110-
boolean hasDefaultValue = KotlinDetector.isKotlinReflectPresent()
111-
&& KotlinDetector.isKotlinType(parameter.getDeclaringClass())
112-
&& KotlinDelegate.hasDefaultValue(nestedParameter);
109+
boolean hasDefaultValue = KotlinDetector.isKotlinReflectPresent() &&
110+
KotlinDetector.isKotlinType(parameter.getDeclaringClass()) &&
111+
KotlinDelegate.hasDefaultValue(nestedParameter);
113112

114113
Object resolvedName = resolveEmbeddedValuesAndExpressions(namedValueInfo.name);
115114
if (resolvedName == null) {
@@ -336,6 +335,7 @@ public NamedValueInfo(String name, boolean required, @Nullable String defaultVal
336335
}
337336
}
338337

338+
339339
/**
340340
* Inner class to avoid a hard dependency on Kotlin at runtime.
341341
*/
@@ -347,7 +347,9 @@ private static class KotlinDelegate {
347347
*/
348348
public static boolean hasDefaultValue(MethodParameter parameter) {
349349
Method method = parameter.getMethod();
350-
Assert.notNull(method, () -> "Retrieved null method from MethodParameter: " + parameter);
350+
if (method == null) {
351+
return false;
352+
}
351353
KFunction<?> function = ReflectJvmMapping.getKotlinFunction(method);
352354
if (function != null) {
353355
int index = 0;
@@ -360,4 +362,5 @@ public static boolean hasDefaultValue(MethodParameter parameter) {
360362
return false;
361363
}
362364
}
365+
363366
}

spring-web/src/main/java/org/springframework/web/service/invoker/AbstractNamedValueArgumentResolver.java

-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public abstract class AbstractNamedValueArgumentResolver implements HttpServiceA
4848

4949
protected final Log logger = LogFactory.getLog(getClass());
5050

51-
5251
@Nullable
5352
private final ConversionService conversionService;
5453

@@ -263,7 +262,6 @@ public NamedValueInfo(
263262
public NamedValueInfo update(String name, boolean required, @Nullable String defaultValue) {
264263
return new NamedValueInfo(name, required, defaultValue, this.label, this.multiValued);
265264
}
266-
267265
}
268266

269267
}

spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractNamedValueArgumentResolver.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import org.springframework.core.ReactiveAdapterRegistry;
3838
import org.springframework.lang.Nullable;
3939
import org.springframework.ui.Model;
40-
import org.springframework.util.Assert;
4140
import org.springframework.web.bind.WebDataBinder;
4241
import org.springframework.web.bind.annotation.ValueConstants;
4342
import org.springframework.web.reactive.BindingContext;
@@ -227,9 +226,9 @@ private Mono<Object> getDefaultValue(NamedValueInfo namedValueInfo, String resol
227226

228227
return Mono.fromSupplier(() -> {
229228
Object value = null;
230-
boolean hasDefaultValue = KotlinDetector.isKotlinReflectPresent()
231-
&& KotlinDetector.isKotlinType(parameter.getDeclaringClass())
232-
&& KotlinDelegate.hasDefaultValue(parameter);
229+
boolean hasDefaultValue = KotlinDetector.isKotlinReflectPresent() &&
230+
KotlinDetector.isKotlinType(parameter.getDeclaringClass()) &&
231+
KotlinDelegate.hasDefaultValue(parameter);
233232
if (namedValueInfo.defaultValue != null) {
234233
value = resolveEmbeddedValuesAndExpressions(namedValueInfo.defaultValue);
235234
}
@@ -328,6 +327,7 @@ public NamedValueInfo(String name, boolean required, @Nullable String defaultVal
328327
}
329328
}
330329

330+
331331
/**
332332
* Inner class to avoid a hard dependency on Kotlin at runtime.
333333
*/
@@ -339,7 +339,9 @@ private static class KotlinDelegate {
339339
*/
340340
public static boolean hasDefaultValue(MethodParameter parameter) {
341341
Method method = parameter.getMethod();
342-
Assert.notNull(method, () -> "Retrieved null method from MethodParameter: " + parameter);
342+
if (method == null) {
343+
return false;
344+
}
343345
KFunction<?> function = ReflectJvmMapping.getKotlinFunction(method);
344346
if (function != null) {
345347
int index = 0;

0 commit comments

Comments
 (0)