Skip to content

Commit df198a0

Browse files
committed
Merge pull request #22681 from biergit
* gh-22681: Polish "Look in correct context when finding Liquibase beans" Look in correct context when finding Liquibase beans Closes gh-22681
2 parents 49f8943 + 59b1df4 commit df198a0

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/liquibase/LiquibaseEndpoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -62,7 +62,7 @@ public ApplicationLiquibaseBeans liquibaseBeans() {
6262
while (target != null) {
6363
Map<String, LiquibaseBean> liquibaseBeans = new HashMap<>();
6464
DatabaseFactory factory = DatabaseFactory.getInstance();
65-
this.context.getBeansOfType(SpringLiquibase.class)
65+
target.getBeansOfType(SpringLiquibase.class)
6666
.forEach((name, liquibase) -> liquibaseBeans.put(name, createReport(liquibase, factory)));
6767
ApplicationContext parent = target.getParent();
6868
contextBeans.put(target.getId(),

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/liquibase/LiquibaseEndpointTests.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ void liquibaseReportIsReturned() {
6262
});
6363
}
6464

65+
@Test
66+
void liquibaseReportIsReturnedForContextHierarchy() {
67+
this.contextRunner.withUserConfiguration().run((parent) -> {
68+
this.contextRunner.withUserConfiguration(Config.class).withParent(parent).run((context) -> {
69+
Map<String, LiquibaseBean> liquibaseBeans = context.getBean(LiquibaseEndpoint.class).liquibaseBeans()
70+
.getContexts().get(parent.getId()).getLiquibaseBeans();
71+
assertThat(liquibaseBeans.get("liquibase").getChangeSets()).hasSize(1);
72+
});
73+
});
74+
}
75+
6576
@Test
6677
void invokeWithCustomSchema() {
6778
this.contextRunner.withUserConfiguration(Config.class)

0 commit comments

Comments
 (0)