diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataProperties.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataProperties.java index 6edecf41547..cdf18ae00a3 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataProperties.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -119,14 +119,14 @@ class ConfigDataProperties { if (activationContext == null) { return false; } - boolean activate = isActive(activationContext.getCloudPlatform()); + CloudPlatform cloudPlatform = activationContext.getCloudPlatform(); + boolean activate = isActive((cloudPlatform != null) ? cloudPlatform : CloudPlatform.NONE); activate = activate && isActive(activationContext.getProfiles()); return activate; } private boolean isActive(CloudPlatform cloudPlatform) { - return this.onCloudPlatform == null || this.onCloudPlatform == CloudPlatform.NONE && cloudPlatform == null - || this.onCloudPlatform == cloudPlatform; + return this.onCloudPlatform == null || this.onCloudPlatform == cloudPlatform; } private boolean isActive(Profiles profiles) { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataPropertiesTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataPropertiesTests.java index 3b45e84f7e3..b3635903f2e 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataPropertiesTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataPropertiesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -100,7 +100,7 @@ class ConfigDataPropertiesTests { } @Test - void isActiveWhenSpecificNoneCloudPlatformAgainstNullCloudPlatform() { + void isActiveWhenNoneCloudPlatformAgainstNullCloudPlatform() { ConfigDataProperties properties = new ConfigDataProperties(NO_IMPORTS, new Activate(CloudPlatform.NONE, null)); ConfigDataActivationContext context = new ConfigDataActivationContext(NULL_CLOUD_PLATFORM, NULL_PROFILES); assertThat(properties.isActive(context)).isTrue();