spring-projects / spring-projects/spring-boot

Add Property origin information to environment

Open
#21,613 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Java
Stars
81.5k
Forks
42.7k
Avg merge
2d 4h
Merged PRs (30d)
65

Description

I already posted an feature request to Spring Framework but it might involve more trouble than it is worth to them. https://github.com/spring-projects/spring-framework/issues/25157

Regardless short of that becoming available could Spring Boot implement an Environment interface that exposes the Origin and OriginLookup functionality.

For example instead of this:

private String getPropertySourceName(String property, Environment environment) {
    String propertySourceName = "";
     if (environment instanceof AbstractEnvironment) {
          MutablePropertySources propertySources = ((AbstractEnvironment) environment).getPropertySources();
          for (PropertySource<?> propertySource : propertySources) {
               Object propertyValue = propertySource.getProperty(property);
               if (propertyValue != null) {
                    if (propertySource instanceof OriginLookup) {
                         Origin origin = ((OriginLookup) propertySource).getOrigin(property);
                         propertySourceName = origin.toString();
                    } 
                    else {
                         propertySourceName = propertySource.getName();
                    }
                    break;
               }
          }
     }
     return propertySourceName;
}

I would like to do this:

private String getPropertySourceName(String property, Environment environment) {
     if (environment instanceof OriginTrackedEnvironment) {
          OriginTrackedEnvironment originTrackedEnvironment = ((OriginTrackedEnvironment) environment);
          return originTrackedEnvironment.getOrigin(property).toString();
     } 
     else {
          return "Unknown Origin";
     }
}

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 by reading the linked Spring Framework issue and the Environment, Origin, and OriginLookup entry points referenced here. Determine whether Spring Boot should expose origin information through its Environment interface and what compatibility constraints apply. Done means an agreed design and corresponding implementation scope, but the issue does not name files or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.