Skip to content

PropertySourcesPropertyValues glitch with CompositePropertySource #2608

Closed
@konrad-garus

Description

@konrad-garus

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions