Add more gap between the orders

Closes gh-38684
This commit is contained in:
Moritz Halbritter 2024-03-26 08:46:04 +01:00
parent cd1d223deb
commit c944ee3074
2 changed files with 11 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 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.
@ -98,7 +98,7 @@ public class CloudFoundryVcapEnvironmentPostProcessor implements EnvironmentPost
private final Log logger;
// Before ConfigDataEnvironmentPostProcessor so values there can use these
private int order = ConfigDataEnvironmentPostProcessor.ORDER - 1;
private int order = ConfigDataEnvironmentPostProcessor.ORDER - 5;
/**
* Create a new {@link CloudFoundryVcapEnvironmentPostProcessor} instance.

View File

@ -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.
@ -21,6 +21,7 @@ import java.util.function.Supplier;
import org.junit.jupiter.api.Test;
import org.springframework.boot.cloud.CloudFoundryVcapEnvironmentPostProcessor;
import org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.test.context.support.TestPropertySourceUtils;
@ -32,6 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Dave Syer
* @author Andy Wilkinson
* @author Moritz Halbritter
*/
class CloudFoundryVcapEnvironmentPostProcessorTests {
@ -119,6 +121,12 @@ class CloudFoundryVcapEnvironmentPostProcessorTests {
assertThat(getProperty("vcap.services.mysql.credentials.port")).isEqualTo("3306");
}
@Test
void orderShouldBeBeforeConfigDataEnvironmentPostProcessorWithGap() {
assertThat(this.initializer.getOrder()).isLessThan(ConfigDataEnvironmentPostProcessor.ORDER);
assertThat(this.initializer.getOrder()).isLessThan(ConfigDataEnvironmentPostProcessor.ORDER - 1);
}
private String getProperty(String key) {
return this.context.getEnvironment().getProperty(key);
}