WangzJi commented on code in PR #7705:
URL: https://github.com/apache/incubator-seata/pull/7705#discussion_r2438622082
##########
seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/main/java/org/apache/seata/spring/boot/autoconfigure/loader/SeataPropertiesLoader.java:
##########
@@ -60,10 +60,7 @@ public class SeataPropertiesLoader implements
ApplicationContextInitializer<Conf
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
ConfigurableEnvironment environment =
applicationContext.getEnvironment();
- if
(ObjectHolder.INSTANCE.getObject(OBJECT_KEY_SPRING_CONFIGURABLE_ENVIRONMENT) ==
null) {
- ObjectHolder.INSTANCE.setObject(
- OBJECT_KEY_SPRING_CONFIGURABLE_ENVIRONMENT,
applicationContext.getEnvironment());
- }
+
ObjectHolder.INSTANCE.setObject(OBJECT_KEY_SPRING_CONFIGURABLE_ENVIRONMENT,
environment);
Review Comment:
@funky-eyes Thanks for the review!
The key point: **Line 64 triggers `ConfigurationFactory` static
initialization**, which needs a complete environment.
With the old null check:
- `EnvironmentPostProcessor` sets environment (without
application.properties in Spring Cloud)
- `ApplicationContextInitializer` skips updating (due to null check)
- `ConfigurationFactory` gets incomplete environment → can't read
`seata.config.type` from application.properties
Unconditional update ensures:
- Always use `ApplicationContextInitializer`'s environment (which has all
property sources loaded)
- Safe because it's always more complete than `EnvironmentPostProcessor`'s
This explains why bootstrap.yml workaround works - it's loaded early
enough.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]