spring-projects / spring-projects/spring-framework

YAML support under PropertiesLoaderUtils

Open
#37,066 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
60.2k
Forks
38.8k
Avg merge
5d 2h
Merged PRs (30d)
27

Description

Enhancements requests

Currently https://github.com/spring-projects/spring-framework/blob/main/spring-core/src/main/java/org/springframework/core/io/support/PropertiesLoaderUtils.java#L92 provides support for parsing XML & .properties file. But it fails to parse if the properties file is defined as YAML.

Right now PropertiesLoaderUtils already checks for XML file extension & it can similarly check for YAML file extension & replace the current parsing logic with a custom implementation.

I agree that currently this can be achieved by providing a custom implementation of PropertySourceFactory as below without the need of any external library dependency

public class YamlPropertySourceFactory implements PropertySourceFactory {

    @Override
    public PropertiesPropertySource createPropertySource(String name, EncodedResource resource) {
        YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
        factory.setResources(resource.getResource());
        Properties properties = factory.getObject();
        String sourceName = (name != null) ? name : resource.getResource().getFilename();
        return new PropertiesPropertySource(sourceName, properties);
    }
}

Though considering that YAML format is getting more traction(start.spring.io started supporting YAML format last year), can an out of box support be considered for supporting YAML files?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with spring-core/src/main/java/org/springframework/core/io/support/PropertiesLoaderUtils.java at the XML-handling logic around line 92. Review how XML and .properties resources are parsed, then determine the expected YAML resource handling and extension checks. Done means YAML files are supported by PropertiesLoaderUtils without regressing existing XML or .properties behavior; the issue does not name a test file.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, yaml
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.