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:
commit
8ab965c981
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -104,13 +104,13 @@ public final class ServerSentEvent<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
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 + ']');
|
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
|
* @param <T> the type of data that this event contains
|
||||||
* @return the builder
|
* @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
|
* @param <T> the type of data that this event contains
|
||||||
* @return the builder
|
* @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
|
* @param <T> the type of data that this event contains
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -35,7 +35,6 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import org.springframework.core.KotlinDetector;
|
import org.springframework.core.KotlinDetector;
|
||||||
import org.springframework.core.MethodParameter;
|
import org.springframework.core.MethodParameter;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.Assert;
|
|
||||||
import org.springframework.web.bind.ServletRequestBindingException;
|
import org.springframework.web.bind.ServletRequestBindingException;
|
||||||
import org.springframework.web.bind.WebDataBinder;
|
import org.springframework.web.bind.WebDataBinder;
|
||||||
import org.springframework.web.bind.annotation.ValueConstants;
|
import org.springframework.web.bind.annotation.ValueConstants;
|
||||||
|
@ -107,9 +106,9 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
|
||||||
|
|
||||||
NamedValueInfo namedValueInfo = getNamedValueInfo(parameter);
|
NamedValueInfo namedValueInfo = getNamedValueInfo(parameter);
|
||||||
MethodParameter nestedParameter = parameter.nestedIfOptional();
|
MethodParameter nestedParameter = parameter.nestedIfOptional();
|
||||||
boolean hasDefaultValue = KotlinDetector.isKotlinReflectPresent()
|
boolean hasDefaultValue = KotlinDetector.isKotlinReflectPresent() &&
|
||||||
&& KotlinDetector.isKotlinType(parameter.getDeclaringClass())
|
KotlinDetector.isKotlinType(parameter.getDeclaringClass()) &&
|
||||||
&& KotlinDelegate.hasDefaultValue(nestedParameter);
|
KotlinDelegate.hasDefaultValue(nestedParameter);
|
||||||
|
|
||||||
Object resolvedName = resolveEmbeddedValuesAndExpressions(namedValueInfo.name);
|
Object resolvedName = resolveEmbeddedValuesAndExpressions(namedValueInfo.name);
|
||||||
if (resolvedName == null) {
|
if (resolvedName == null) {
|
||||||
|
@ -336,6 +335,7 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inner class to avoid a hard dependency on Kotlin at runtime.
|
* 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) {
|
public static boolean hasDefaultValue(MethodParameter parameter) {
|
||||||
Method method = parameter.getMethod();
|
Method method = parameter.getMethod();
|
||||||
Assert.notNull(method, () -> "Retrieved null method from MethodParameter: " + parameter);
|
if (method == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
KFunction<?> function = ReflectJvmMapping.getKotlinFunction(method);
|
KFunction<?> function = ReflectJvmMapping.getKotlinFunction(method);
|
||||||
if (function != null) {
|
if (function != null) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
@ -360,4 +362,5 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,6 @@ public abstract class AbstractNamedValueArgumentResolver implements HttpServiceA
|
||||||
|
|
||||||
protected final Log logger = LogFactory.getLog(getClass());
|
protected final Log logger = LogFactory.getLog(getClass());
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private final ConversionService conversionService;
|
private final ConversionService conversionService;
|
||||||
|
|
||||||
|
@ -263,7 +262,6 @@ public abstract class AbstractNamedValueArgumentResolver implements HttpServiceA
|
||||||
public NamedValueInfo update(String name, boolean required, @Nullable String defaultValue) {
|
public NamedValueInfo update(String name, boolean required, @Nullable String defaultValue) {
|
||||||
return new NamedValueInfo(name, required, defaultValue, this.label, this.multiValued);
|
return new NamedValueInfo(name, required, defaultValue, this.label, this.multiValued);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,6 @@ import org.springframework.core.MethodParameter;
|
||||||
import org.springframework.core.ReactiveAdapterRegistry;
|
import org.springframework.core.ReactiveAdapterRegistry;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.util.Assert;
|
|
||||||
import org.springframework.web.bind.WebDataBinder;
|
import org.springframework.web.bind.WebDataBinder;
|
||||||
import org.springframework.web.bind.annotation.ValueConstants;
|
import org.springframework.web.bind.annotation.ValueConstants;
|
||||||
import org.springframework.web.reactive.BindingContext;
|
import org.springframework.web.reactive.BindingContext;
|
||||||
|
@ -227,9 +226,9 @@ public abstract class AbstractNamedValueArgumentResolver extends HandlerMethodAr
|
||||||
|
|
||||||
return Mono.fromSupplier(() -> {
|
return Mono.fromSupplier(() -> {
|
||||||
Object value = null;
|
Object value = null;
|
||||||
boolean hasDefaultValue = KotlinDetector.isKotlinReflectPresent()
|
boolean hasDefaultValue = KotlinDetector.isKotlinReflectPresent() &&
|
||||||
&& KotlinDetector.isKotlinType(parameter.getDeclaringClass())
|
KotlinDetector.isKotlinType(parameter.getDeclaringClass()) &&
|
||||||
&& KotlinDelegate.hasDefaultValue(parameter);
|
KotlinDelegate.hasDefaultValue(parameter);
|
||||||
if (namedValueInfo.defaultValue != null) {
|
if (namedValueInfo.defaultValue != null) {
|
||||||
value = resolveEmbeddedValuesAndExpressions(namedValueInfo.defaultValue);
|
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.
|
* 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) {
|
public static boolean hasDefaultValue(MethodParameter parameter) {
|
||||||
Method method = parameter.getMethod();
|
Method method = parameter.getMethod();
|
||||||
Assert.notNull(method, () -> "Retrieved null method from MethodParameter: " + parameter);
|
if (method == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
KFunction<?> function = ReflectJvmMapping.getKotlinFunction(method);
|
KFunction<?> function = ReflectJvmMapping.getKotlinFunction(method);
|
||||||
if (function != null) {
|
if (function != null) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
Loading…
Reference in New Issue