Commit 0286128b authored by Stephane Nicoll's avatar Stephane Nicoll

Deprecate exceptionIfInvalid

This commit deprecates the `exceptionIfInvalid` feature as we have now a
way to select the `@ConfigurationProperties` object to validate (i.e. add
`@Validated` on them).

Closes gh-8027
parent 393cfe50
......@@ -186,7 +186,10 @@ public class PropertiesConfigurationFactory<T>
* Set a flag to indicate that an exception should be raised if a Validator is
* available and validation fails.
* @param exceptionIfInvalid the flag to set
* @deprecated as of 1.5, do not specify a {@link Validator} if validation should not
* occur
*/
@Deprecated
public void setExceptionIfInvalid(boolean exceptionIfInvalid) {
this.exceptionIfInvalid = exceptionIfInvalid;
}
......
......@@ -86,7 +86,10 @@ public @interface ConfigurationProperties {
* it is set to false, validation errors will be swallowed. They will be logged, but
* not propagated to the caller.
* @return the flag value (default true)
* @deprecated as of 1.5 since validation only kicks in when {@code @Validated} is
* present
*/
@Deprecated
boolean exceptionIfInvalid() default true;
}
......@@ -304,6 +304,7 @@ public class ConfigurationPropertiesBindingPostProcessor implements BeanPostProc
return bean;
}
@SuppressWarnings("deprecation")
private void postProcessBeforeInitialization(Object bean, String beanName,
ConfigurationProperties annotation) {
Object target = bean;
......
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
......@@ -84,6 +84,7 @@ public class PropertiesConfigurationFactoryTests {
}
@Test
@Deprecated
public void testValidationErrorCanBeSuppressed() throws Exception {
this.validator = new SpringValidatorAdapter(
Validation.buildDefaultValidatorFactory().getValidator());
......
......@@ -185,6 +185,7 @@ public class EnableConfigurationPropertiesTests {
}
@Test
@Deprecated
public void testNoExceptionOnValidation() {
this.context.register(NoExceptionIfInvalidTestConfiguration.class);
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context,
......@@ -452,6 +453,7 @@ public class EnableConfigurationPropertiesTests {
@Configuration
@EnableConfigurationProperties(NoExceptionIfInvalidTestProperties.class)
@Deprecated
protected static class NoExceptionIfInvalidTestConfiguration {
}
......@@ -711,6 +713,7 @@ public class EnableConfigurationPropertiesTests {
@ConfigurationProperties(exceptionIfInvalid = false)
@Validated
@Deprecated
protected static class NoExceptionIfInvalidTestProperties extends TestProperties {
@NotNull
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment