Browse Source

Improve exception message when configuration class parsing fails

This commit improves the exception that is thrown when a particular
source class cannot be parsed. Previously, the message would include
the root configuration class, which may not be the class that
actually failed as parsing can trigger component scan. There's now
a dedicated catch that generates an exception message that includes the
class that is currently parsed.

Closes gh-31146
pull/30079/head
Stéphane Nicoll 1 year ago
parent
commit
d23263619a
  1. 9
      spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java

9
spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java

@ -238,11 +238,18 @@ class ConfigurationClassParser { @@ -238,11 +238,18 @@ class ConfigurationClassParser {
}
// Recursively process the configuration class and its superclass hierarchy.
SourceClass sourceClass = asSourceClass(configClass, filter);
SourceClass sourceClass = null;
try {
sourceClass = asSourceClass(configClass, filter);
do {
sourceClass = doProcessConfigurationClass(configClass, sourceClass, filter);
}
while (sourceClass != null);
}
catch (IOException ex) {
throw new BeanDefinitionStoreException(
"I/O failure while processing configuration class [" + sourceClass + "]", ex);
}
this.configurationClasses.put(configClass, configClass);
}

Loading…
Cancel
Save