After migrating to snakeyaml 1.27 my application properties are not deserialized

Issue #1066 invalid
Ovidiu Popa created an issue

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)

  1. Andrey Somov

    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]

  2. Andrey Somov

    can you please make it in such a way that only changing the dependency will make the difference ?

  3. Alexander Maslov

    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.

  4. Log in to comment