Hello,

As per the comments on #18126, here's a PR that adds a property to @LiquibaseDataSource to be able to use a DataSourceClosingSpringLiquibase with minimal effort when defining your own datasource bean.

This is by opposition to now where you must rely on LiquibaseProperties or lose most advantages of the LiquibaseAutoConfiguration.

Note that as mentionned in the issue conversation, retrieving the @LiquibaseDataSource annotation on the bean declaration is not easy. The solution here is less than ideal, but I could not find much better.

There are some nicer ways via the bean registry or some concrete context implementations, but I am not familiar enough with how these are picked to make safe assumptions by myself

Let me know if anything is not acceptable.

Thanks

Comment From: Tristan971

I've found an issue when the datasource that's auto closed being exposed as a bean means it's picked up by the datasource health auto indicator, which doesn't really like finding the pool closed. Not sure if the good move is to filter it out once it closes or to on the contrary support a closed datasource pool as "healthy" in that case. The second sounds really contrived to me so I would think of the first as better ; opinions?

Comment From: wilkinsona

@Tristan971 That's an interesting problem and we're not sure what the best solution is at the moment. Unfortunately that means we need to park this one for now and come back to it once 2.2. has been released and we've started planning the 2.3 release.

Comment From: Tristan971

Thanks for the feedback, I agree this sounds like it's a little more side-effects than expected initially. Hopefully there's a solution that we just haven't thought of yet, but otherwise it just might be not worth it I suppose

Comment From: philwebb

Thanks for the PR @Tristan971. We're going to have another look at the original issue to see if we can implement a callback based approach. We're worried that closing an externally defined bean will cause other issues. Thanks anyway for the PR and sorry it has taken us so long to review.

Please follow #18126 for updates

Comment From: Tristan971

No worries :slightly_smiling_face: