diff --git a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEvent.java b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEvent.java index b2bf41162d..af85c2c6a7 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEvent.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEvent.java @@ -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 { @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 the type of data that this event contains * @return the builder */ @@ -119,7 +119,7 @@ public final class ServerSentEvent { } /** - * 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 the type of data that this event contains * @return the builder */ @@ -129,7 +129,7 @@ public final class ServerSentEvent { /** - * A mutable builder for a {@code SseEvent}. + * A mutable builder for a {@code ServerSentEvent}. * * @param the type of data that this event contains */ diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/AbstractNamedValueMethodArgumentResolver.java b/spring-web/src/main/java/org/springframework/web/method/annotation/AbstractNamedValueMethodArgumentResolver.java index f8a08687bd..145d108f0a 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/AbstractNamedValueMethodArgumentResolver.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/AbstractNamedValueMethodArgumentResolver.java @@ -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; } } + } diff --git a/spring-web/src/main/java/org/springframework/web/service/invoker/AbstractNamedValueArgumentResolver.java b/spring-web/src/main/java/org/springframework/web/service/invoker/AbstractNamedValueArgumentResolver.java index 88fd07c94e..238a5e8586 100644 --- a/spring-web/src/main/java/org/springframework/web/service/invoker/AbstractNamedValueArgumentResolver.java +++ b/spring-web/src/main/java/org/springframework/web/service/invoker/AbstractNamedValueArgumentResolver.java @@ -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); } - } } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractNamedValueArgumentResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractNamedValueArgumentResolver.java index 408ecee7aa..25b177af66 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractNamedValueArgumentResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractNamedValueArgumentResolver.java @@ -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;