Fix the order in which the postprocessors run. (#1333)
This commit is contained in:
committed by
GitHub
parent
a292134b0f
commit
b1e8d6a08c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 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.
|
||||
@@ -19,6 +19,7 @@ package org.springframework.cloud.client;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor;
|
||||
import org.springframework.boot.context.properties.bind.Bindable;
|
||||
import org.springframework.boot.context.properties.bind.Binder;
|
||||
import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
|
||||
@@ -32,15 +33,17 @@ import org.springframework.core.env.MapPropertySource;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
* @author Olga Maciaszek-Sharma
|
||||
*/
|
||||
public class HostInfoEnvironmentPostProcessor implements EnvironmentPostProcessor, Ordered {
|
||||
|
||||
// Before BootstrapConfigFileApplicationListener
|
||||
private int order = Ordered.HIGHEST_PRECEDENCE + 9;
|
||||
// Before BootstrapConfigFileApplicationListener, but after
|
||||
// ConfigDataEnvironmentPostProcessor
|
||||
private static final int ORDER = Math.addExact(ConfigDataEnvironmentPostProcessor.ORDER, 1);
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return this.order;
|
||||
return ORDER;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2020 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -85,7 +85,7 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* {@link EnvironmentPostProcessor} that configures the context environment by loading
|
||||
* properties from well known file locations. By default properties will be loaded from
|
||||
* properties from well known file locations. By default, properties will be loaded from
|
||||
* 'application.properties' and/or 'application.yml' files in the following locations:
|
||||
* <ul>
|
||||
* <li>file:./config/</li>
|
||||
@@ -116,6 +116,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Eddú Meléndez
|
||||
* @author Madhura Bhave
|
||||
* @author Scott Frederick
|
||||
* @author Olga Maciaszek-Sharma
|
||||
* @since 1.0.0 {@link ConfigDataEnvironmentPostProcessor}
|
||||
*/
|
||||
public class BootstrapConfigFileApplicationListener
|
||||
@@ -168,9 +169,9 @@ public class BootstrapConfigFileApplicationListener
|
||||
*/
|
||||
public static final int DEFAULT_ORDER =
|
||||
// This listener needs to run after the `ConfigDataEnvironmentPostProcessor`
|
||||
// to
|
||||
// make sure the `Environment.activeProfiles` are correctly set
|
||||
Math.addExact(ConfigDataEnvironmentPostProcessor.ORDER, 1);
|
||||
// and `HostInfoEnvironmentPostProcessor`
|
||||
// to make sure the `Environment.activeProfiles` are correctly set
|
||||
Math.addExact(ConfigDataEnvironmentPostProcessor.ORDER, 2);
|
||||
|
||||
private final Log logger;
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -40,7 +40,7 @@ import static org.mockito.Mockito.when;
|
||||
import static org.springframework.cloud.loadbalancer.core.LoadBalancerTestUtils.buildLoadBalancerClientFactory;
|
||||
|
||||
/**
|
||||
* Tests for {@link SubsetServiceInstanceListSupplier}
|
||||
* Tests for {@link SubsetServiceInstanceListSupplier}.
|
||||
*
|
||||
* @author Zhuozhi Ji
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user