Skip to content

Commit

Permalink
Fix bean validation with Coroutines
Browse files Browse the repository at this point in the history
Removing the usage of KotlinReflectionParameterNameDiscoverer in
LocalValidatorFactoryBean and just delegate to Hibernate Validator
fixed the use case with suspending functions.

Closes spring-projectsgh-23499
  • Loading branch information
sdeleuze committed Jan 18, 2023
1 parent 64de6de commit 5121fc0
Showing 1 changed file with 3 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -49,8 +49,6 @@
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;
Expand Down Expand Up @@ -118,13 +116,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.
Expand Down Expand Up @@ -196,9 +187,8 @@ public void setConstraintValidatorFactory(ConstraintValidatorFactory constraintV
/**
* 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) {
Expand Down

0 comments on commit 5121fc0

Please sign in to comment.