-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spring Boot: better support relativeToChangelogfile when ResourceLoaders return FilteredReactiveWebContextResources #2758
Conversation
…ilePath To make changelogs from liquibase 3.x.x with sqlFile path referring to an sql file in the same dir with relativeToChangelogFile="true" work with 4.x.x liquibase#2281
…uibase into erik-meuwese-topicus-patch-2
…on and within an overridable method
@erik-meuwese-topicus thanks for tracking down and describing the I am not able to reproduce the problem to see your change fix it due to not getting spring set up in whatever configuration exposes it, but I understand how this can solve it. I did push a change where I extracted the DefaultResourceLoader creation to the constructor and made a new I also updated the description to have it a bit more focused on the exists() problem vs. a more generic "fixes spring boot". Let me know if there is anything I got wrong in that change. I also took the "Fixes" link to 2281 off since I'm not sure this fully fixes that overly generic "addresses spring issues" issue, and I don't want merging this to close the issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review and test results:
Things to be aware of
- I couldn't reproduce the problem to see the fix work, but I was able to tell the change didn't break the setup I had
- Fix improves the handling within certain spring boot setups without impacting others by falling back to the old logic if the new lookup doesn't find a resource
Things to worry about
- No tests added, but I need to spend more time that we have right now to figure out the right way to integrate spring testing into our suite. Unit tests didn't seem like they'd add enough value to come up with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Code change introduces an appropriate redundancy check for ensuring Liquibase loads the expected classpath.
- Change is limited to Spring Boot.
Please Note! @nvoxland (Liquibase Founder) and several other Liquibase Engineers reviewed the code change and deem it low risk. However, there are no automated functional tests in place for Spring Boot. Be advised there is a larger possibility of unexpected side-effect due to the change than for similar changes with robust testing in place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I submitted a PR approval but just noticed that the build did not complete. Requesting that the build run and pass all developer-level tests prior to merging this fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build passed!
APPROVED
[nvoxland] this fixed our issue, thanks |
Pull Request Type
Description
Subclasses of FilteredReactiveWebContextResource and potentially others, make
exists() always returns false in order to avoid exposing the whole classpath in a non-servlet environment.
which impacts Liquibase's logic in figuring out relative paths.The change to SpringResourceAccessor to rely on exists() was introduced in Liquibase 4.0, so this will fix some changelogs that worked in 3.x but not any versions.
Improves spring support as mentioned in #2281 for at least some configurations.
Example Fixed Scenario
file:/...../target/classes/liquibase/init/test.xml
file:/...../target/classes/liquibase/init/test.sql
Liquibase 4.9.1 fails to find test.sql relative to test.xml which contains the changelog
Actual Behavior
Expected/Desired Behavior