changelog is found twice in classpath
See original GitHub issueEnvironment
This is potentially a duplicate of https://github.com/liquibase/liquibase/issues/1916 / https://github.com/liquibase/liquibase/issues/1916#issuecomment-1116361306, but since that’s closed, I’m opening a new issue.
Liquibase Version: 4.0.0, 4.1.0, 4.3.2, 4.3.3, 4.3.4, 4.3.5, 4.4.0, 4.4.1, 4.4.2, 4.4.3, 4.5.0, 4.6.0, 4.6.1, 4.6.2, 4.7.0, 4.7.1, 4.8.0, 4.9.0, and 4.9.1 Liquibase Integration & Version: gradle, spring boot 2.2.13, 2.3.12
Liquibase Extension(s) & Version:
Database Vendor & Version:
Operating System Type & Version:
Description
liquibase throws an exception that a changelog file is on the classpath twice. Here’s the stacktrace from liquibase 4.9.1:
Caused by: liquibase.exception.ChangeLogParseException: Error parsing classpath:db/healthcheck.yml
at liquibase.parser.core.yaml.YamlChangeLogParser.parse(YamlChangeLogParser.java:89)
at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:369)
at liquibase.Liquibase.lambda$update$1(Liquibase.java:224)
at liquibase.Scope.lambda$child$0(Scope.java:180)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:179)
at liquibase.Scope.child(Scope.java:158)
at liquibase.Liquibase.runInScope(Liquibase.java:2405)
at liquibase.Liquibase.update(Liquibase.java:211)
at liquibase.Liquibase.update(Liquibase.java:197)
at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:314)
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:269)
at com.netflix.spinnaker.kork.sql.migration.SpringLiquibaseProxy.afterPropertiesSet(SpringLiquibaseProxy.kt:65)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1858)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1795)
... 87 more
Caused by: java.io.IOException: Found 2 files that match classpath:db/healthcheck.yml: file:/Users/dbyron/src/spinnaker/kork/kork-sql/build/resources/main/db/healthcheck.yml, jar:file:/Users/dbyron/src/spinnaker/kork/kork-sql/build/libs/kork-sql.jar!/db/healthcheck.yml
at liquibase.resource.AbstractResourceAccessor.openStream(AbstractResourceAccessor.java:25)
at liquibase.parser.core.yaml.YamlChangeLogParser.parse(YamlChangeLogParser.java:25)
... 101 more
Steps To Reproduce
This happens in kork, with:
$ ./gradlew kork-sql:test
I tried adding a test to SpringResourceAccessorTest.groovy, but I’m not familiar enough with mvn to get a test to run after packaging the jar, so it passes. I believe the mvn terminology for the kind of test I’m looking for is an integration test.
def "openStreams for a file in src/main/resources"() {
when:
def list = resourceAccessor.openStreams(null, "classpath:/liquibase/examples/yaml/example-changelog.yaml")
then:
list.size() == 1
}
I believe this commit is the one that made this stop working in 4.3.2, when it worked in 4.3.1, specifically the change to finalizeSearchPath that unconditionally prepends classpath*:
.
I single-stepped through SpringResourceAccessor.openStreams. In 4.3.1, the return value from
ResourcePatternUtils.getResourcePatternResolver(resourceLoader).getResources(searchPath);
is an array with one classpath resource element. searchPath in this case is classpath:db/healthcheck.yml
. In 4.3.2 though, searchPath is classpath*:/db/healthcheck.yml
and the return value is (perhaps obviously) an array with two elements:
URL [file:/Users/dbyron/src/spinnaker/kork/kork-sql/build/resources/main/db/healthcheck.yml]
URL [jar:file:/Users/dbyron/src/spinnaker/kork/kork-sql/build/libs/kork-sql.jar!/db/healthcheck.yml]
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:27 (11 by maintainers)
Top GitHub Comments
@dbyron-sf @mamtananavati @JanCizmar 4.13 is out https://github.com/liquibase/liquibase/releases/tag/v4.13.0
@kataggart thanks, had planned on doing so anyway: #3282. Also stated there why #3119 is not applicable.