After migrating to snakeyaml 1.27 my application properties are not deserialized
I have generated a project using spring boot 2.4.x, and the application.yml is now longer deserialized as it should.
If I override the snakeyaml version to 1.26 in the pom.xml it works fine.
The problem is that empty objects {} are no longer ignored and the conversion fails, which makes sense.
I attached a sample project.
Comments (7)
-
-
can you please make it in such a way that only changing the dependency will make the difference ?
-
- changed status to new
-
- marked as minor
-
assigned issue to
-
I have tried with both versions, but it fails. From time to time actually it passes in eclipse. I don’t know why. This feels like spring-boot thing.
SnakeYaml correctly loads things as empty LinkedHashMap. Spring-Boot uses its own Constructor which extends SafeConstructor. It means that SnakeYaml does not create any instances (JavaBeans) except Map,Set,List,Number,Boolean,String.
I can see in the issue in spring-boot https://github.com/spring-projects/spring-boot/issues/35403 (I guess reported by you) nice comment with some links explaining why empty Maps/Lists might not work in spring-boot configuration.
-
@Ovidiu Popa can you please help ?
-
- changed status to invalid
Abandoned by the reporter
- Log in to comment
How can I reproduce the issue ? I tried to run the tests with both versions of SnakeYAML (uncommenting the dependency in the POM). In both cases I got:
Caused by: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.util.LinkedHashMap<?, ?>] to type [com.example.demo.properties.Config$Address]