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
This commit is contained in:
Juergen Hoeller 2024-09-30 11:17:55 +02:00
commit 8ab965c981
4 changed files with 20 additions and 17 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2024 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.
@ -104,13 +104,13 @@ public final class ServerSentEvent<T> {
@Override
public String toString() {
return ("ServerSentEvent [id = '" + this.id + "\', event='" + this.event + "\', retry=" +
return ("ServerSentEvent [id = '" + this.id + "', event='" + this.event + "', retry=" +
this.retry + ", comment='" + this.comment + "', data=" + this.data + ']');
}
/**
* Return a builder for a {@code SseEvent}.
* Return a builder for a {@code ServerSentEvent}.
* @param <T> the type of data that this event contains
* @return the builder
*/
@ -119,7 +119,7 @@ public final class ServerSentEvent<T> {
}
/**
* Return a builder for a {@code SseEvent}, populated with the given {@linkplain #data() data}.
* Return a builder for a {@code ServerSentEvent}, populated with the given {@linkplain #data() data}.
* @param <T> the type of data that this event contains
* @return the builder
*/
@ -129,7 +129,7 @@ public final class ServerSentEvent<T> {
/**
* A mutable builder for a {@code SseEvent}.
* A mutable builder for a {@code ServerSentEvent}.
*
* @param <T> the type of data that this event contains
*/

View File

@ -35,7 +35,6 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.core.KotlinDetector;
import org.springframework.core.MethodParameter;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.ValueConstants;
@ -107,9 +106,9 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
NamedValueInfo namedValueInfo = getNamedValueInfo(parameter);
MethodParameter nestedParameter = parameter.nestedIfOptional();
boolean hasDefaultValue = KotlinDetector.isKotlinReflectPresent()
&& KotlinDetector.isKotlinType(parameter.getDeclaringClass())
&& KotlinDelegate.hasDefaultValue(nestedParameter);
boolean hasDefaultValue = KotlinDetector.isKotlinReflectPresent() &&
KotlinDetector.isKotlinType(parameter.getDeclaringClass()) &&
KotlinDelegate.hasDefaultValue(nestedParameter);
Object resolvedName = resolveEmbeddedValuesAndExpressions(namedValueInfo.name);
if (resolvedName == null) {
@ -336,6 +335,7 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
}
}
/**
* Inner class to avoid a hard dependency on Kotlin at runtime.
*/
@ -347,7 +347,9 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
*/
public static boolean hasDefaultValue(MethodParameter parameter) {
Method method = parameter.getMethod();
Assert.notNull(method, () -> "Retrieved null method from MethodParameter: " + parameter);
if (method == null) {
return false;
}
KFunction<?> function = ReflectJvmMapping.getKotlinFunction(method);
if (function != null) {
int index = 0;
@ -360,4 +362,5 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
return false;
}
}
}

View File

@ -48,7 +48,6 @@ public abstract class AbstractNamedValueArgumentResolver implements HttpServiceA
protected final Log logger = LogFactory.getLog(getClass());
@Nullable
private final ConversionService conversionService;
@ -263,7 +262,6 @@ public abstract class AbstractNamedValueArgumentResolver implements HttpServiceA
public NamedValueInfo update(String name, boolean required, @Nullable String defaultValue) {
return new NamedValueInfo(name, required, defaultValue, this.label, this.multiValued);
}
}
}

View File

@ -37,7 +37,6 @@ import org.springframework.core.MethodParameter;
import org.springframework.core.ReactiveAdapterRegistry;
import org.springframework.lang.Nullable;
import org.springframework.ui.Model;
import org.springframework.util.Assert;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.ValueConstants;
import org.springframework.web.reactive.BindingContext;
@ -227,9 +226,9 @@ public abstract class AbstractNamedValueArgumentResolver extends HandlerMethodAr
return Mono.fromSupplier(() -> {
Object value = null;
boolean hasDefaultValue = KotlinDetector.isKotlinReflectPresent()
&& KotlinDetector.isKotlinType(parameter.getDeclaringClass())
&& KotlinDelegate.hasDefaultValue(parameter);
boolean hasDefaultValue = KotlinDetector.isKotlinReflectPresent() &&
KotlinDetector.isKotlinType(parameter.getDeclaringClass()) &&
KotlinDelegate.hasDefaultValue(parameter);
if (namedValueInfo.defaultValue != null) {
value = resolveEmbeddedValuesAndExpressions(namedValueInfo.defaultValue);
}
@ -328,6 +327,7 @@ public abstract class AbstractNamedValueArgumentResolver extends HandlerMethodAr
}
}
/**
* Inner class to avoid a hard dependency on Kotlin at runtime.
*/
@ -339,7 +339,9 @@ public abstract class AbstractNamedValueArgumentResolver extends HandlerMethodAr
*/
public static boolean hasDefaultValue(MethodParameter parameter) {
Method method = parameter.getMethod();
Assert.notNull(method, () -> "Retrieved null method from MethodParameter: " + parameter);
if (method == null) {
return false;
}
KFunction<?> function = ReflectJvmMapping.getKotlinFunction(method);
if (function != null) {
int index = 0;