javaspringspring-bootsnakeyaml

I'm getting totally wrong String value from the application.yaml file in the Spring Boot app.The value in yaml config is 044525266 and in var 9611958


May be this is because of leading zero?

acquiring:
  bic: 044525266

in yaml is loaded through

   @Autowired
    public AcquiringService(
...
                            @Value("${acquiring.bic}") String bic,
...
)

The Spring Boot version is: 2.1.8.RELEASE

It uses library org.yaml:snakeyaml:1.23

enter image description here


Solution

  • As you've pointed out, quotes fix the issue. The reason can be found in the YAML 1.1 spec.

    Example 2.19. Integers

    canonical: 12345
    decimal: +12,345
    sexagesimal: 3:25:45
    octal: 014 <<<<<<<
    hexadecimal: 0xC

    In YAML 1.2, octals use 0o instead of 0.

    So 044525266 in octal becomes 9611958 in decimal.

    For correct usage is should use quotes

    acquiring:
      bic: "044525266"