InvalidConfigDataPropertyException Class — spring-boot Architecture
Architecture documentation for the InvalidConfigDataPropertyException class in InvalidConfigDataPropertyException.java from the spring-boot codebase.
Entity Profile
Relationship Graph
Source Code
core/spring-boot/src/main/java/org/springframework/boot/context/config/InvalidConfigDataPropertyException.java lines 39–155
public class InvalidConfigDataPropertyException extends ConfigDataException {
private static final Map<ConfigurationPropertyName, ConfigurationPropertyName> ERRORS;
static {
Map<ConfigurationPropertyName, ConfigurationPropertyName> errors = new LinkedHashMap<>();
errors.put(ConfigurationPropertyName.of("spring.profiles"),
ConfigurationPropertyName.of("spring.config.activate.on-profile"));
errors.put(ConfigurationPropertyName.of("spring.profiles[0]"),
ConfigurationPropertyName.of("spring.config.activate.on-profile"));
ERRORS = Collections.unmodifiableMap(errors);
}
private static final Set<ConfigurationPropertyName> PROFILE_SPECIFIC_ERRORS;
static {
Set<ConfigurationPropertyName> errors = new LinkedHashSet<>();
errors.add(Profiles.INCLUDE_PROFILES);
errors.add(Profiles.INCLUDE_PROFILES.append("[0]"));
errors.add(ConfigurationPropertyName.of(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME));
errors.add(ConfigurationPropertyName.of(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME + "[0]"));
errors.add(ConfigurationPropertyName.of(AbstractEnvironment.DEFAULT_PROFILES_PROPERTY_NAME));
errors.add(ConfigurationPropertyName.of(AbstractEnvironment.DEFAULT_PROFILES_PROPERTY_NAME + "[0]"));
PROFILE_SPECIFIC_ERRORS = Collections.unmodifiableSet(errors);
}
private final ConfigurationProperty property;
private final @Nullable ConfigurationPropertyName replacement;
private final @Nullable ConfigDataResource location;
InvalidConfigDataPropertyException(ConfigurationProperty property, boolean profileSpecific,
@Nullable ConfigurationPropertyName replacement, @Nullable ConfigDataResource location) {
super(getMessage(property, profileSpecific, replacement, location), null);
this.property = property;
this.replacement = replacement;
this.location = location;
}
/**
* Return source property that caused the exception.
* @return the invalid property
*/
public ConfigurationProperty getProperty() {
return this.property;
}
/**
* Return the {@link ConfigDataResource} of the invalid property or {@code null} if
* the source was not loaded from {@link ConfigData}.
* @return the config data location or {@code null}
*/
public @Nullable ConfigDataResource getLocation() {
return this.location;
}
/**
* Return the replacement property that should be used instead or {@code null} if not
* replacement is available.
* @return the replacement property name
*/
public @Nullable ConfigurationPropertyName getReplacement() {
return this.replacement;
}
/**
* Throw an {@link InvalidConfigDataPropertyException} if the given
* {@link ConfigDataEnvironmentContributor} contains any invalid property.
* @param contributor the contributor to check
*/
static void throwIfPropertyFound(ConfigDataEnvironmentContributor contributor) {
ConfigurationPropertySource propertySource = contributor.getConfigurationPropertySource();
if (propertySource != null) {
ERRORS.forEach((name, replacement) -> {
ConfigurationProperty property = propertySource.getConfigurationProperty(name);
if (property != null) {
throw new InvalidConfigDataPropertyException(property, false, replacement,
contributor.getResource());
}
});
if (contributor.isFromProfileSpecificImport()
&& !contributor.hasConfigDataOption(ConfigData.Option.IGNORE_PROFILES)) {
PROFILE_SPECIFIC_ERRORS.forEach((name) -> {
ConfigurationProperty property = propertySource.getConfigurationProperty(name);
if (property != null) {
throw new InvalidConfigDataPropertyException(property, true, null, contributor.getResource());
}
});
}
}
}
private static String getMessage(ConfigurationProperty property, boolean profileSpecific,
@Nullable ConfigurationPropertyName replacement, @Nullable ConfigDataResource location) {
StringBuilder message = new StringBuilder("Property '");
message.append(property.getName());
if (location != null) {
message.append("' imported from location '");
message.append(location);
}
message.append("' is invalid");
if (profileSpecific) {
message.append(" in a profile specific resource");
}
if (replacement != null) {
message.append(" and should be replaced with '");
message.append(replacement);
message.append("'");
}
if (property.getOrigin() != null) {
message.append(" [origin: ");
message.append(property.getOrigin());
message.append("]");
}
return message.toString();
}
}
Domain
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free