Skip to content

Liquibase actuator does not give correct information when multiple databases are used in one project #19146

Closed
@bvpelt

Description

@bvpelt

Spring Boot 2.2.1.RELEASE
Operating System Windows 10
JVM 1.8

When in a springboot project multiple databases are used then:

  • springboot liquibase rolls out changes but...
  • when accessing the liquibase acuator it only shows the executed changelog for one of the liquibase beans.

In org.springframework.boot.actuate.liquibase.LiquibaseEndpoint
the following code seems the problem

	@ReadOperation
	public ApplicationLiquibaseBeans liquibaseBeans() {
		ApplicationContext target = this.context;
		Map<String, ContextLiquibaseBeans> contextBeans = new HashMap<>();
		while (target != null) {
			Map<String, LiquibaseBean> liquibaseBeans = new HashMap<>();
			DatabaseFactory factory = DatabaseFactory.getInstance();
			StandardChangeLogHistoryService service = new StandardChangeLogHistoryService();
			this.context.getBeansOfType(SpringLiquibase.class)
					.forEach((name, liquibase) -> liquibaseBeans.put(name, createReport(liquibase, service, factory)));
			ApplicationContext parent = target.getParent();
			contextBeans.put(target.getId(),
					new ContextLiquibaseBeans(liquibaseBeans, (parent != null) ? parent.getId() : null));
			target = parent;
		}
		return new ApplicationLiquibaseBeans(contextBeans);
	}

Especially:

	StandardChangeLogHistoryService service = new StandardChangeLogHistoryService();
	this.context.getBeansOfType(SpringLiquibase.class)
					.forEach((name, liquibase) -> liquibaseBeans.put(name, 		createReport(liquibase, service, factory)));

cases the problem. As stated in the code for each bean a report is created, but the same StandardChangeLogHistoryService is used each time, while it should be a new service for each call.

Example code is copied.
liquibasedemo.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: supersededAn issue that has been superseded by anothertype: bugA general bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions