`relativeToChangeLogFile` not working with `SpringResource#resolveSibling`
See original GitHub issueEnvironment
Liquibase Version: 4.17
Liquibase Integration & Version: Spring Boot 3.0.0-RC1
Operating System Type & Version: Windows 10
Description
Folder structure:
src/main/resources/db/changelog/
├── changelog.xml
└── data.csv
changelog.xml:
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.5.xsd">
<changeSet id="relative import" author="kzander91">
<createTable tableName="my_table">
<column name="test_col" type="bigint"/>
</createTable>
<loadData tableName="my_table"
file="data.csv"
relativeToChangelogFile="true">
<column name="test_col" type="bigint"/>
</loadData>
</changeSet>
</databaseChangeLog>
The loadData
change resolves file
to /data.csv
instead of /db/data.csv
. This worked previously with 4.9.1 and broke with 4.17.0.
The bug is located in SpringResource
:
https://github.com/liquibase/liquibase/blob/c9ceb05141eee992c7aaa3002451bb5f531b49d5/liquibase-core/src/main/java/liquibase/integration/spring/SpringResource.java#L40-L49
If resource
is a org.springframework.core.io.UrlResource
, createRelative()
uses new URL(URL, String)
to resolve the relative URL:
https://github.com/spring-projects/spring-framework/blob/v6.0.0-RC2/spring-core/src/main/java/org/springframework/core/io/UrlResource.java#L310-L317
This effectively calls
new URL(new URL("file://C:/Temp/demo/target/classes/db/changelog/changelog.xml"), "../data.csv")
Which resolves to file://C:/Temp/demo/target/classes/db/data.csv
instead of file://C:/Temp/demo/target/classes/db/changelog/data.csv
.
Steps To Reproduce
- Use
<loadData relativeToChangelogFile="true"/>
. - Start migration with Spring Boot.
Actual Behavior
Relative file is resolved incorrectly, migration aborts due to “unknown file”.
Expected/Desired Behavior
Relative paths are resolved correctly as before.
Reproducer
- Unzip and run
mvnw test
, test fails. - Uncomment
liquibase.version
property in pom and rerun: test succeeds.
Possibly related
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:10 (5 by maintainers)
Top GitHub Comments
Hello, @OleksandrShkurat -
The 4.18.0 tag was added when we started our internal release process. Regressions were found which necessitated rework, but the tag in git was not removed during that time. We are still working to get the 4.18.0 release out. There are lots of boring, internal reasons this is the case, but I promise, we’re working on it. My apologies for the wait; I too, want to see this released!
-erzsebet (XDelphiGrl)
Thank you. I already updated my project yesterday