Skip to content

PropertySourcesPropertyValues glitch with CompositePropertySource #2608

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

Closed
konrad-garus opened this issue Mar 5, 2015 · 3 comments
Closed
Assignees
Labels
type: bug A general bug
Milestone

Comments

@konrad-garus
Copy link

PropertySourcesPropertyValues.processPropertySource does the following:

private void processPropertySource(PropertySource<?> source,
        PropertySourcesPropertyResolver resolver,
        PropertyNamePatternsMatcher includes, Collection<String> exacts) {
    if (source instanceof EnumerablePropertySource) {
        processEnumerablePropertySource((EnumerablePropertySource<?>) source,
                resolver, includes, exacts);
    }
    else if (source instanceof CompositePropertySource) {
        processCompositePropertySource((CompositePropertySource) source, resolver,
                includes, exacts);
    }
    else {
        // We can only do exact matches for non-enumerable property names, but
        // that's better than nothing...
        processDefaultPropertySource(source, resolver, includes, exacts);
    }
}

Since Spring 4.1.2, CompositePropertySource extends EnumerablePropertySource.

There are two issues with it:

  1. The second branch of the condition (first "else") is never executed (dead code).
  2. CompositePropertySource does not actually fulfil the specification of EnumerablePropertySource. It may contain a non-enumerable property source in which case getPropertyNames does not in fact list all the properties.

The latter is arguably an issue in Spring core. But it has negative effect on Spring Boot as well, so it probably should be fixed in the core or worked around in Boot.

@konrad-garus
Copy link
Author

Bug report in core: https://jira.spring.io/browse/SPR-12788

@jhoeller
Copy link

jhoeller commented Mar 5, 2015

So I suppose flipping Boot's instanceof cascade to check for CompositePropertySource first would fix the immediate problem here?

@konrad-garus
Copy link
Author

@jhoeller Yes, it seems like it would be a good workaround for that core glitch here in Boot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants