Fixes https://github.com/spring-projects/spring-boot/issues/25433
add isAutoDetectionEnabled method to determine that whether it is enabled that the platform is detected by looking for platform-specific environment variables.
Comment From: wilkinsona
Thanks for the pull request, @nguyensach. An alternative approach would be to change the condition. It could get the active CloudPlatform and see if it matches the required platform rather than checking if the required platform is active. I think I prefer what you've proposed here but I want to check with the team to see if the current behaviour of CloudPlatform
is intentional. The follow code is in ConfigDataActivationContext
:
https://github.com/spring-projects/spring-boot/blob/59d8c976344e47d7fdb95ae96424b15b11358147/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataActivationContext.java#L58-L65
It's making me wonder if there are some subtleties here that I'm overlooking. By calling isEnforced on each CloudPlatform and then falling back to getActive
it seems to be allowing a CloudPlatform to be enforced ahead of an earlier one that would have been detected as active.
Comment From: nguyensach
@wilkinsona Thanks for your response. I think that the code in ConfigDataActivationContext
is right. When deduceCloudPlatform
method is called, there is not actived profile.
https://github.com/spring-projects/spring-boot/blob/59d8c976344e47d7fdb95ae96424b15b11358147/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataActivationContext.java#L37-L38
Therefore, All CloudPlatform#isEnforced(environment)
will be false.
Comment From: philwebb
Thanks very much @nguyensach for contributing to Spring Boot. This is now in 2.3.x, 2.4.x and 2.5.x