Fix bean validation on suspending function parameters
This commit leverages Hibernate Validator's own internal use of standard Java reflection to perform validation on suspending function, which fixes the ArrayIndexOutOfBoundsException previously observed. Validation of suspending function return values remains unsupported as Hibernate Validator is not Coroutines aware. Closes gh-23499
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -49,8 +49,6 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.core.KotlinDetector;
|
||||
import org.springframework.core.KotlinReflectionParameterNameDiscoverer;
|
||||
import org.springframework.core.ParameterNameDiscoverer;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -75,6 +73,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* {@code jakarta.validation} API being present but no explicit Validator having been configured.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Sebastien Deleuze
|
||||
* @since 3.0
|
||||
* @see jakarta.validation.ValidatorFactory
|
||||
* @see jakarta.validation.Validator
|
||||
@@ -118,13 +117,6 @@ public class LocalValidatorFactoryBean extends SpringValidatorAdapter
|
||||
private ValidatorFactory validatorFactory;
|
||||
|
||||
|
||||
public LocalValidatorFactoryBean() {
|
||||
if (KotlinDetector.isKotlinReflectPresent()) {
|
||||
this.parameterNameDiscoverer = new KotlinReflectionParameterNameDiscoverer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specify the desired provider class, if any.
|
||||
* <p>If not specified, JSR-303's default search mechanism will be used.
|
||||
@@ -196,9 +188,8 @@ public class LocalValidatorFactoryBean extends SpringValidatorAdapter
|
||||
/**
|
||||
* Set the ParameterNameDiscoverer to use for resolving method and constructor
|
||||
* parameter names if needed for message interpolation.
|
||||
* <p>Default is Hibernate Validator's own internal use of standard Java reflection,
|
||||
* with an additional {@link KotlinReflectionParameterNameDiscoverer} if Kotlin
|
||||
* is present. This may be overridden with a custom subclass or a Spring-controlled
|
||||
* <p>Default is Hibernate Validator's own internal use of standard Java reflection.
|
||||
* This may be overridden with a custom subclass or a Spring-controlled
|
||||
* {@link org.springframework.core.DefaultParameterNameDiscoverer} if necessary.
|
||||
*/
|
||||
public void setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer) {
|
||||
|
||||
Reference in New Issue
Block a user