Polishing (aligned with main)

This commit is contained in:
Juergen Hoeller
2026-01-27 21:25:23 +01:00
parent 7b7126ae3d
commit 1ec3cb4d5f
7 changed files with 19 additions and 25 deletions
@@ -377,47 +377,45 @@ public class LocalValidatorFactoryBean extends SpringValidatorAdapter
protected void postProcessConfiguration(Configuration<?> configuration) {
}
private ValidatorFactory obtainValidatorFactory() {
Assert.state(this.validatorFactory != null, "No target ValidatorFactory set");
return this.validatorFactory;
}
@Override
public Validator getValidator() {
Assert.state(this.validatorFactory != null, "No target ValidatorFactory set");
return this.validatorFactory.getValidator();
return obtainValidatorFactory().getValidator();
}
@Override
public ValidatorContext usingContext() {
Assert.state(this.validatorFactory != null, "No target ValidatorFactory set");
return this.validatorFactory.usingContext();
return obtainValidatorFactory().usingContext();
}
@Override
public MessageInterpolator getMessageInterpolator() {
Assert.state(this.validatorFactory != null, "No target ValidatorFactory set");
return this.validatorFactory.getMessageInterpolator();
return obtainValidatorFactory().getMessageInterpolator();
}
@Override
public TraversableResolver getTraversableResolver() {
Assert.state(this.validatorFactory != null, "No target ValidatorFactory set");
return this.validatorFactory.getTraversableResolver();
return obtainValidatorFactory().getTraversableResolver();
}
@Override
public ConstraintValidatorFactory getConstraintValidatorFactory() {
Assert.state(this.validatorFactory != null, "No target ValidatorFactory set");
return this.validatorFactory.getConstraintValidatorFactory();
return obtainValidatorFactory().getConstraintValidatorFactory();
}
@Override
public ParameterNameProvider getParameterNameProvider() {
Assert.state(this.validatorFactory != null, "No target ValidatorFactory set");
return this.validatorFactory.getParameterNameProvider();
return obtainValidatorFactory().getParameterNameProvider();
}
@Override
public ClockProvider getClockProvider() {
Assert.state(this.validatorFactory != null, "No target ValidatorFactory set");
return this.validatorFactory.getClockProvider();
return obtainValidatorFactory().getClockProvider();
}
@Override
@@ -427,8 +425,8 @@ public class LocalValidatorFactoryBean extends SpringValidatorAdapter
try {
return super.unwrap(type);
}
catch (ValidationException ex) {
// Ignore - we'll try ValidatorFactory unwrapping next
catch (ValidationException ignored) {
// Trying ValidatorFactory unwrapping next
}
}
if (this.validatorFactory != null) {
@@ -26,7 +26,7 @@ import org.springframework.context.support.MessageSourceResourceBundle;
import org.springframework.util.Assert;
/**
* Implementation of Hibernate Validator 4.3/5.x's {@link ResourceBundleLocator} interface,
* Implementation of Hibernate Validator's {@link ResourceBundleLocator} interface,
* exposing a Spring {@link MessageSource} as localized {@link MessageSourceResourceBundle}.
*
* @author Juergen Hoeller
@@ -39,6 +39,7 @@ public class MessageSourceResourceBundleLocator implements ResourceBundleLocator
private final MessageSource messageSource;
/**
* Build a MessageSourceResourceBundleLocator for the given MessageSource.
* @param messageSource the Spring MessageSource to wrap
@@ -48,6 +49,7 @@ public class MessageSourceResourceBundleLocator implements ResourceBundleLocator
this.messageSource = messageSource;
}
@Override
public ResourceBundle getResourceBundle(Locale locale) {
return new MessageSourceResourceBundle(this.messageSource, locale);