Upgrade to Liquibase 3.3.0
This commit updates Spring Boot to Liquibase 3.3.0 and makes the necessary changes to Boot's PackageScanClassResolver. Previously, when a class found by the scan could not be loaded a warning message was logged. This commit lowers these to debug level, bringing them into line with logging that the standard Liquibase implementation does. It also avoids a warning always being logged at startup due to Liquibase's WatchCommand$DynamicContentHandler which depends on Jetty (an optional dependency of Liquibase). Closes gh-1382
This commit is contained in:
		
							parent
							
								
									a3d4e92d9f
								
							
						
					
					
						commit
						ce4400291b
					
				| 
						 | 
				
			
			@ -92,7 +92,7 @@
 | 
			
		|||
		<json-path.version>0.9.1</json-path.version>
 | 
			
		||||
		<jstl.version>1.2</jstl.version>
 | 
			
		||||
		<junit.version>4.11</junit.version>
 | 
			
		||||
		<liquibase.version>3.0.8</liquibase.version>
 | 
			
		||||
		<liquibase.version>3.3.0</liquibase.version>
 | 
			
		||||
		<log4j.version>1.2.17</log4j.version>
 | 
			
		||||
		<log4j2.version>2.0.2</log4j2.version>
 | 
			
		||||
		<logback.version>1.1.2</logback.version>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,11 +17,9 @@
 | 
			
		|||
package org.springframework.boot.liquibase;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
import liquibase.servicelocator.DefaultPackageScanClassResolver;
 | 
			
		||||
import liquibase.servicelocator.PackageScanClassResolver;
 | 
			
		||||
import liquibase.servicelocator.PackageScanFilter;
 | 
			
		||||
 | 
			
		||||
import org.apache.commons.logging.Log;
 | 
			
		||||
import org.springframework.core.io.Resource;
 | 
			
		||||
| 
						 | 
				
			
			@ -48,16 +46,15 @@ public class SpringPackageScanClassResolver extends DefaultPackageScanClassResol
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	protected void find(PackageScanFilter test, String packageName, ClassLoader loader,
 | 
			
		||||
			Set<Class<?>> classes) {
 | 
			
		||||
	protected void findAllClasses(String packageName, ClassLoader loader) {
 | 
			
		||||
		MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(
 | 
			
		||||
				loader);
 | 
			
		||||
		try {
 | 
			
		||||
			Resource[] resources = scan(loader, packageName);
 | 
			
		||||
			for (Resource resource : resources) {
 | 
			
		||||
				Class<?> candidate = loadClass(loader, metadataReaderFactory, resource);
 | 
			
		||||
				if (candidate != null && test.matches(candidate)) {
 | 
			
		||||
					classes.add(candidate);
 | 
			
		||||
				Class<?> clazz = loadClass(loader, metadataReaderFactory, resource);
 | 
			
		||||
				if (clazz != null) {
 | 
			
		||||
					addFoundClass(clazz);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -80,12 +77,21 @@ public class SpringPackageScanClassResolver extends DefaultPackageScanClassResol
 | 
			
		|||
			MetadataReader reader = readerFactory.getMetadataReader(resource);
 | 
			
		||||
			return ClassUtils.forName(reader.getClassMetadata().getClassName(), loader);
 | 
			
		||||
		}
 | 
			
		||||
		catch (Exception ex) {
 | 
			
		||||
			if (this.logger.isWarnEnabled()) {
 | 
			
		||||
				this.logger.warn("Ignoring cadidate class resource " + resource, ex);
 | 
			
		||||
		catch (NoClassDefFoundError ex) {
 | 
			
		||||
			handleFailure(resource, ex);
 | 
			
		||||
			return null;
 | 
			
		||||
		}
 | 
			
		||||
		catch (Exception ex) {
 | 
			
		||||
			handleFailure(resource, ex);
 | 
			
		||||
			return null;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void handleFailure(Resource resource, Throwable ex) {
 | 
			
		||||
		if (this.logger.isDebugEnabled()) {
 | 
			
		||||
			this.logger.debug("Ignoring candidate class resource " + resource
 | 
			
		||||
					+ " due to " + ex);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue