SnakeYAML 2.x (Spring Boot 3.2) Compatibility
netmikey opened this issue · comments
Hi there,
While DBRider works well for me using Spring Boot 3.0 and 3.1, it seems to break with Spring Boot 3.2. I'm getting the following error:
java.lang.NullPointerException: Cannot invoke "com.github.database.rider.core.configuration.DBUnitConfig.executorId(String)" because the return value of "com.github.database.rider.core.configuration.DBUnitConfig.fromGlobalConfig()" is null
at com.github.database.rider.core.dataset.DataSetExecutorImpl.instance(DataSetExecutorImpl.java:76)
at com.github.database.rider.junit5.DBUnitExtension.createDBUnitTestContext(DBUnitExtension.java:101)
at com.github.database.rider.junit5.DBUnitExtension.lambda$getTestContext$0(DBUnitExtension.java:95)
at com.github.database.rider.junit5.DBUnitExtension.getTestContext(DBUnitExtension.java:95)
at com.github.database.rider.junit5.DBUnitExtension.beforeTestExecution(DBUnitExtension.java:53)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
This starts happening in a project that worked well with Spring Boot 3.1, without any change but the Spring Boot update to 3.2.
Edit:
While I was debugging this, I found the cause: SnakeYAML 2.x (which Spring Boot 3.2 depends on) is throwing the following error:
Global tag is not allowed: tag:yaml.org,2002:com.github.database.rider.core.api.configuration.Orthography
in 'reader', line 1, column 26:
caseInsensitiveStrategy: !!com.github.database.rider.core ...
^
at org.yaml.snakeyaml.composer.Composer.composeScalarNode(Composer.java:231)
at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:205)
at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:369)
at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:348)
at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:323)
at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:209)
at org.yaml.snakeyaml.composer.Composer.getNode(Composer.java:131)
at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:157)
at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:178)
at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:493)
at org.yaml.snakeyaml.Yaml.loadAs(Yaml.java:486)
at com.github.database.rider.core.configuration.DBUnitConfig.loadDbUnitConfig(DBUnitConfig.java:128)
at java.base/java.util.Optional.map(Optional.java:260)
at com.github.database.rider.core.configuration.DBUnitConfig.fromCustomGlobalFile(DBUnitConfig.java:117)
at com.github.database.rider.core.configuration.GlobalConfig.createInstance(GlobalConfig.java:30)
at com.github.database.rider.core.configuration.GlobalConfig.instance(GlobalConfig.java:18)
at com.github.database.rider.core.configuration.DBUnitConfig.fromGlobalConfig(DBUnitConfig.java:210)
at com.github.database.rider.core.dataset.DataSetExecutorImpl.instance(DataSetExecutorImpl.java:76)
at com.github.database.rider.junit5.DBUnitExtension.createDBUnitTestContext(DBUnitExtension.java:101)
at com.github.database.rider.junit5.DBUnitExtension.lambda$getTestContext$0(DBUnitExtension.java:95)
at com.github.database.rider.junit5.DBUnitExtension.getTestContext(DBUnitExtension.java:95)
at com.github.database.rider.junit5.DBUnitExtension.beforeTestExecution(DBUnitExtension.java:53)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
We use a global dbunit.yml
file configured according to the example in the DBRider doc, and it complains about the "!!" in the first line:
caseInsensitiveStrategy: !!com.github.database.rider.core.api.configuration.Orthography 'LOWERCASE'
columnSensing: true
properties:
batchedStatements: true
schema: @SCHEMA@
Switching to @DBUnit
annotations is not an option unfortunately because we need to set @SCHEMA@
to a dynamic value at runtime and as soon as the @DBUnit
annotation is present, the global dbunit.yml
file is ignored.
Edit 2:
Looking further into this, I found the reason why SnakeYAML changed its behavior in v2 (see this post for more details).
I also found a very simple workaround, so DBRider probably only needs a documentation update: Omitting the Enum class altogether and only specifying the desired value seems to work:
caseInsensitiveStrategy: LOWERCASE