version: Spring-Boot 2.2.5
Duplicate code calls "ConfigurationPropertySources.attach(environment);"
see method: org.springframework.boot.SpringApplication#prepareEnvironment
Comment From: wilkinsona
Thanks for the report. The environment conversion may have resulted in a new Environment
with a new MutablePropertySources
instance. The second call to attach
allows this to be detected and the attachment to be updated accordingly.
Comment From: brucelwl
I don't think the first one needs to be called !!! @wilkinsona
Comment From: wilkinsona
I believe it does. If it isn't called, the attachment will not be present when the listeners are being notified that the environment has been prepared or when binding to the SpringApplication
.
Comment From: only-gale
Thanks for the report. The environment conversion may have resulted in a new
Environment
with a newMutablePropertySources
instance. The second call toattach
allows this to be detected and the attachment to be updated accordingly.
So, I'm curious, if no environment conversion is performed, more directly, the if-condition is not fulfilled, the second attach
method still need to be called? I mean, why the second attach
method can't be put into the if statement? @wilkinsona
Comment From: wilkinsona
It possibly could be within the if block. I'd have to spend some time reminding myself exactly what happens and, given the minimal potential benefit, I'm afraid I don't have time right now.