From 74ec5f65d14447beefdda84749181290e9890031 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 28 Oct 2020 10:30:11 +0000 Subject: [PATCH] Make isPresent check more Graal-friendly Closes gh-23925 --- .../LiquibaseServiceLocatorApplicationListener.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/liquibase/LiquibaseServiceLocatorApplicationListener.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/liquibase/LiquibaseServiceLocatorApplicationListener.java index 8a94938673..a3fc0ccafd 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/liquibase/LiquibaseServiceLocatorApplicationListener.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/liquibase/LiquibaseServiceLocatorApplicationListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,10 +37,13 @@ public class LiquibaseServiceLocatorApplicationListener implements ApplicationLi private static final Log logger = LogFactory.getLog(LiquibaseServiceLocatorApplicationListener.class); + private static final boolean LIQUIBASE_PRESENT = ClassUtils.isPresent( + "liquibase.servicelocator.CustomResolverServiceLocator", + LiquibaseServiceLocatorApplicationListener.class.getClassLoader()); + @Override public void onApplicationEvent(ApplicationStartingEvent event) { - if (ClassUtils.isPresent("liquibase.servicelocator.CustomResolverServiceLocator", - event.getSpringApplication().getClassLoader())) { + if (LIQUIBASE_PRESENT) { new LiquibasePresent().replaceServiceLocator(); } }