From edb8952071c3770f87e94aadd6859bbcd57415e5 Mon Sep 17 00:00:00 2001 From: Sharang Gupta Date: Wed, 4 Nov 2026 17:19:17 +0000 Subject: [PATCH] Resolve S3 labels one after another With multiple labels the S3 repository added the profile-specific files of every label before the files without a profile, so an earlier label could override a later one. Resolve each label completely before the next, as the other repositories do, and enable the S3 compliance tests for multiple labels and profile expressions. Signed-off-by: Sharang Gupta --- .../environment/AwsS3EnvironmentRepository.java | 5 ++--- ...wsS3EnvironmentRepositoryComplianceTests.java | 16 ---------------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsS3EnvironmentRepository.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsS3EnvironmentRepository.java index f20581dcf..47acc9e09 100644 --- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsS3EnvironmentRepository.java +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsS3EnvironmentRepository.java @@ -164,6 +164,7 @@ public Environment findOne(String specifiedApplication, String specifiedProfiles private void addPropertySources(Environment environment, List apps, String[] profiles, List labels) { String[] profilesByPrecedence = profilesByPrecedence(profiles); + // Each label is resolved completely before the next one, so the last label wins for (String label : labels) { for (String profile : profilesByPrecedence) { addPropertySourcesForApps(apps, @@ -173,9 +174,7 @@ private void addPropertySources(Environment environment, List apps, Stri addPropertySourcesForApps(apps, app -> addProfileSpecificPropertySource(environment, app, null, profiles, label)); } - } - if (this.searchPaths.isEmpty()) { - for (String label : labels) { + if (this.searchPaths.isEmpty()) { addPropertySourcesForApps(apps, app -> addNonProfileSpecificPropertySource(environment, app, profiles, label)); } diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/compliance/AwsS3EnvironmentRepositoryComplianceTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/compliance/AwsS3EnvironmentRepositoryComplianceTests.java index 5fe5d8b37..cc0a8ff57 100644 --- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/compliance/AwsS3EnvironmentRepositoryComplianceTests.java +++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/compliance/AwsS3EnvironmentRepositoryComplianceTests.java @@ -20,9 +20,7 @@ import java.util.Set; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; import org.testcontainers.containers.localstack.LocalStackContainer.Service; import software.amazon.awssdk.core.sync.RequestBody; import software.amazon.awssdk.services.s3.S3Client; @@ -58,20 +56,6 @@ protected EnvironmentRepositoryFixture fixture() { return this.fixture; } - @Override - @Test - @Disabled("TODO-issue: Documents activated by a profile expression get the lowest precedence") - public void profileExpressionsActivateDocuments() throws Exception { - super.profileExpressionsActivateDocuments(); - } - - @Override - @Test - @Disabled("TODO-issue: Labels are interleaved by profile rather than resolved one after another") - public void lastLabelTakesPrecedence() throws Exception { - super.lastLabelTakesPrecedence(); - } - static class Fixture implements EnvironmentRepositoryFixture { @Override