Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grails 4: Null value in the configuration has been converted to empty String #11524

Open
4 tasks done
puneetbehl opened this issue Apr 20, 2020 · 1 comment
Open
4 tasks done

Comments

@puneetbehl
Copy link
Contributor

puneetbehl commented Apr 20, 2020

Task List

  • Steps to reproduce provided
  • Stacktrace (if present) provided
  • Example that reproduces the problem uploaded to Github
  • Full description of the issue provided (see below)

It looks like it's impossible to have a null value for a give configuration property in the application.yml as it is converted to an empty string. I think the problem is in YamlPropertySourceLoader.java which is responsible for loading properties from the YAML. It calls an underline spring method which flattens the input map and somehow converts a null value to an empty string.

Steps to Reproduce

  1. Create a new Grails 4.0.3 application.
  2. Define a property test: null in the application.yml
  3. In the BootStrap.groovy add an assert to verify that the value is null as:
class BootStrap {

    def grailsApplication

    def init = { servletContext ->

        assert grailsApplication.config.test == null
        ...

Expected Behaviour

The value of the config property should be null.

Actual Behaviour

The assertion would fail as the value is an empty String.

Environment Information

  • Operating System: macOS
  • Grails Version: 4.0.3
  • JDK Version: (AdoptOpenJDK)(build 1.8.0_232-b09)
  • Container Version (If Applicable): N/A

Example Application

https://github.com/puneetbehl/grails-config-problem.git

@puneetbehl
Copy link
Contributor Author

Relates to spring-projects/spring-framework#19986

@puneetbehl puneetbehl removed this from the grails-4.0.4 milestone Jun 10, 2020
@puneetbehl puneetbehl removed their assignment Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant