Improve error handling in SpringPackageScanClassResolver

Previously, SpringPackageScanResolver was handling as subset of the
failures that Liquibase’s DefaultPackageScanResolver handles. This could
lead to a failure due to a LinkageError in certain environments.

This commit updates SpringPackageScanClassResolver to align its error
handling with what Liquibase does.

Fixes gh-1853
pull/1824/merge
Andy Wilkinson 10 years ago
parent 6df001d30f
commit 1a3b0309b3

@ -77,14 +77,21 @@ public class SpringPackageScanClassResolver extends DefaultPackageScanClassResol
MetadataReader reader = readerFactory.getMetadataReader(resource);
return ClassUtils.forName(reader.getClassMetadata().getClassName(), loader);
}
catch (NoClassDefFoundError ex) {
catch (ClassNotFoundException ex) {
handleFailure(resource, ex);
return null;
}
catch (Exception ex) {
catch (LinkageError ex) {
handleFailure(resource, ex);
return null;
}
catch (Throwable ex) {
if (this.logger.isWarnEnabled()) {
this.logger.warn("Unexpected failure when loading class resource "
+ resource, ex);
}
return null;
}
}
private void handleFailure(Resource resource, Throwable ex) {

Loading…
Cancel
Save