Skip to content

Commit

Permalink
fix compatibility for springcloud env config (#944)
Browse files Browse the repository at this point in the history
  • Loading branch information
HzjNeverStop authored Apr 11, 2022
1 parent cce6d8c commit 96b0a06
Showing 1 changed file with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,16 @@
*/
package com.alipay.sofa.boot.listener;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.StreamSupport;

import com.alipay.sofa.boot.constant.SofaBootConstants;
import com.alipay.sofa.boot.util.SofaBootEnvUtils;
import com.alipay.sofa.common.log.env.LogEnvUtils;
import org.springframework.boot.Banner;
import org.springframework.boot.ConfigurableBootstrapContext;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.config.ConfigFileApplicationListener;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.boot.env.EnvironmentPostProcessorApplicationListener;
import org.springframework.context.ApplicationListener;
import org.springframework.core.Ordered;
import org.springframework.core.env.ConfigurableEnvironment;
Expand All @@ -40,9 +36,13 @@
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;

import com.alipay.sofa.boot.constant.SofaBootConstants;
import com.alipay.sofa.boot.util.SofaBootEnvUtils;
import com.alipay.sofa.common.log.env.LogEnvUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.StreamSupport;

/**
* @author qilong.zql
Expand Down Expand Up @@ -126,12 +126,13 @@ public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
.registerShutdownHook(false).logStartupInfo(false).web(WebApplicationType.NONE)
.listeners().initializers().build(event.getArgs());

ConfigurableBootstrapContext bootstrapContext = event.getBootstrapContext();
ApplicationEnvironmentPreparedEvent bootstrapEvent = new ApplicationEnvironmentPreparedEvent(
bootstrapApplication, event.getArgs(), bootstrapEnvironment);
bootstrapContext, bootstrapApplication, event.getArgs(), bootstrapEnvironment);

application.getListeners().stream()
.filter(listener -> listener instanceof ConfigFileApplicationListener)
.forEach(listener -> ((ConfigFileApplicationListener) listener)
.filter(listener -> listener instanceof EnvironmentPostProcessorApplicationListener)
.forEach(listener -> ((EnvironmentPostProcessorApplicationListener) listener)
.onApplicationEvent(bootstrapEvent));

assemblyLogSetting(bootstrapEnvironment);
Expand Down

0 comments on commit 96b0a06

Please sign in to comment.