From 1a3b0309b3c9d506f8ca2bdc646c7728af06ffcb Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 7 Nov 2014 12:35:01 +0000 Subject: [PATCH] Improve error handling in SpringPackageScanClassResolver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../liquibase/SpringPackageScanClassResolver.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/spring-boot/src/main/java/org/springframework/boot/liquibase/SpringPackageScanClassResolver.java b/spring-boot/src/main/java/org/springframework/boot/liquibase/SpringPackageScanClassResolver.java index 6274a49c94..d8db8764a9 100644 --- a/spring-boot/src/main/java/org/springframework/boot/liquibase/SpringPackageScanClassResolver.java +++ b/spring-boot/src/main/java/org/springframework/boot/liquibase/SpringPackageScanClassResolver.java @@ -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) {