From b35a19c8876a9f99a449ec66b3d42a035ad03027 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Fri, 6 Mar 2026 17:46:43 +0100 Subject: [PATCH] Disable cloud features when platform is NONE Prior to this commit, applying the "spring.main.cloud-platform=none" property would apply this choice to the relevant auto-configuration conditions, but the `CloudPlatform` enum itself would still signal that cloud features like header forwarding is enabled. This commit ensures that "NONE" disables such features. Fixes gh-49478 --- .../java/org/springframework/boot/cloud/CloudPlatform.java | 4 ++++ .../org/springframework/boot/cloud/CloudPlatformTests.java | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudPlatform.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudPlatform.java index eec32739851..e63d67b6927 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudPlatform.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudPlatform.java @@ -47,6 +47,10 @@ public enum CloudPlatform { return false; } + @Override + public boolean isUsingForwardHeaders() { + return false; + } }, /** diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/cloud/CloudPlatformTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/cloud/CloudPlatformTests.java index f794be42a12..a942fca55e1 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/cloud/CloudPlatformTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/cloud/CloudPlatformTests.java @@ -243,6 +243,7 @@ class CloudPlatformTests { assertThat(CloudPlatform.KUBERNETES.isEnforced(binder)).isFalse(); } + @Test void isActiveWhenNoCloudPlatformIsEnforcedAndHasKubernetesServiceHostAndKubernetesServicePort() { Map envVars = new HashMap<>(); envVars.put("EXAMPLE_SERVICE_HOST", "---"); @@ -253,6 +254,11 @@ class CloudPlatformTests { .containsExactly(CloudPlatform.NONE); } + @Test + void nonePlatformShouldDisableCloudPlatformFeatures() { + assertThat(CloudPlatform.NONE.isUsingForwardHeaders()).isFalse(); + } + private Environment getEnvironmentWithEnvVariables(Map environmentVariables) { MockEnvironment environment = new MockEnvironment(); PropertySource propertySource = new SystemEnvironmentPropertySource(