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

ConfigurationProperties entry is prefixed with content which is not given via command line configuration #25780

Closed
khmarbaise opened this issue Mar 24, 2021 · 1 comment
Labels
for: external-project For an external project and not something we can fix status: duplicate A duplicate of another issue

Comments

@khmarbaise
Copy link
Contributor

khmarbaise commented Mar 24, 2021

Currently I have a project (excerpt from a larger project) with the following class:

@Component
@ConfigurationProperties("xyz")
public class ConfigurationLeiDaD {

  private static final Logger LOG = LoggerFactory.getLogger(ConfigurationLeiDaD.class);

  private static final String DEFAULT_INBOUND = "inbound";

  private Path baseDirectory;
  private Path inbound;

  ConfigurationLeiDaD() {
    this.baseDirectory = null;
    this.inbound = null;
  }

  public Path getBaseDirectory() {
    return baseDirectory;
  }

  void setBaseDirectory(Path baseDirectory) {
    this.baseDirectory = baseDirectory;
  }

  public Path getInbound() {
    return Objects.requireNonNullElseGet(this.inbound, () -> this.baseDirectory.resolve(DEFAULT_INBOUND));
  }

}

Furthermore I have simple service which uses the above configuration which just prints out the information on the console:

@Service
public class FirstService {

  private static final Logger LOG = LoggerFactory.getLogger(FirstService.class);

  private final ConfigurationLeiDaD configurationLeiDaD;

  public FirstService(ConfigurationLeiDaD configurationLeiDaD) {
    this.configurationLeiDaD = configurationLeiDaD;
  }

  @EventListener(classes = ApplicationReadyEvent.class)
  void applicationReady(@NonNull ApplicationReadyEvent event) {
    LOG.info("Event {}", event);
    Path inbound = configurationLeiDaD.getInbound();
    LOG.info("inbound: {}", inbound);
  }

}

I'm starting the spring boot (Spring Boot Version 2.4.3) app via:

java -jar target/spring-boot-issue-1.0.0-SNAPSHOT-exec.jar --xyz.base-directory=/Absolute/Directory/Path/

The output of the application on console looks like this (excerpt):

2021-03-24 16:17:05.119  INFO 45592 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2021-03-24 16:17:05.316  INFO 45592 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2021-03-24 16:17:05.325  INFO 45592 --- [           main] io.soebes.simple.MainApplication         : Started MainApplication in 1.772 seconds (JVM running for 2.197)
2021-03-24 16:17:05.327  INFO 45592 --- [           main] io.soebes.simple.service.FirstService    : Event org.springframework.boot.context.event.ApplicationReadyEvent[source=org.springframework.boot.SpringApplication@3f23a3a0]
2021-03-24 16:17:05.328  INFO 45592 --- [           main] io.soebes.simple.service.FirstService    : inbound: /Absolute/Directory/Path/inbound

As you can see in the output of the value is just give as expected.

Now I simply change the Spring Boot version from 2.4.3 to 2.4.4 and rebuild the project and call it the same way:

But now the output looks like:

2021-03-24 16:15:43.073  INFO 45553 --- [           main] i.s.simple.config.ConfigurationLeiDaD    : baseDirectory /private/var/folders/gb/sw0f5qsx4m95znm_fjw3nfwh0000gn/T/tomcat-docbase.8080.10431842645162390813/Absolute/Directory/Path
2021-03-24 16:15:43.201  INFO 45553 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2021-03-24 16:15:43.404  INFO 45553 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2021-03-24 16:15:43.415  INFO 45553 --- [           main] io.soebes.simple.MainApplication         : Started MainApplication in 2.04 seconds (JVM running for 2.477)
2021-03-24 16:15:43.417  INFO 45553 --- [           main] io.soebes.simple.service.FirstService    : Event org.springframework.boot.context.event.ApplicationReadyEvent[source=org.springframework.boot.SpringApplication@5fb97279]
2021-03-24 16:15:43.417  INFO 45553 --- [           main] io.soebes.simple.service.FirstService    : inbound: /private/var/folders/gb/sw0f5qsx4m95znm_fjw3nfwh0000gn/T/tomcat-docbase.8080.10431842645162390813/Absolute/Directory/Path/inbound

As you can see the output of the absolute directory is prefixed by something which is not given via command line...

I have created a small project to reproduce this.

https://github.com/khmarbaise/spring-boot-issue

Just change the version for Spring Boot Version from 2.4.3 to 2.4.4 and call the command line as described in the above examples.

The question is now: Do I have missed something to read in the release notes of 2.4.4 ? Or is there something else I'm missing?

  • JDK 11.0.9
  • Maven 3.6.3 (for building)
  • Spring Boot 2.4.3/2.4.4
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 24, 2021
@wilkinsona
Copy link
Member

Thanks for the report. This is a duplicate of spring-projects/spring-framework#26702.

@wilkinsona wilkinsona added status: duplicate A duplicate of another issue for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants