fix: fix NPE when application context is null (#1787)

pull/1788/head
Fishtail 6 months ago committed by GitHub
parent 4651fc917e
commit 27fc828960
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -20,3 +20,4 @@
- [fix: fix cb rule no update bug.](https://github.com/Tencent/spring-cloud-tencent/pull/1786)
- [feat: support traffic gray lane router](https://github.com/Tencent/spring-cloud-tencent/pull/1785)
- [fix: kafka lane support dynamic lane tag.](https://github.com/Tencent/spring-cloud-tencent/pull/1784)
- [fix: fix NPE when application context is null #1787](https://github.com/Tencent/spring-cloud-tencent/pull/1787)

@ -28,6 +28,7 @@ import org.springframework.boot.context.logging.LoggingApplicationListener;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.cloud.context.environment.EnvironmentChangeEvent;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.event.GenericApplicationListener;
import org.springframework.core.ResolvableType;
import org.springframework.core.env.ConfigurableEnvironment;
@ -69,7 +70,11 @@ public class PolarisLoggingApplicationListener implements GenericApplicationList
environment = ((ApplicationEnvironmentPreparedEvent) applicationEvent).getEnvironment();
}
else if (ApplicationFailedEvent.class.isAssignableFrom(applicationEvent.getClass())) {
environment = ((ApplicationFailedEvent) applicationEvent).getApplicationContext().getEnvironment();
ConfigurableApplicationContext configurableApplicationContext = ((ApplicationFailedEvent) applicationEvent)
.getApplicationContext();
if (configurableApplicationContext != null) {
environment = configurableApplicationContext.getEnvironment();
}
}
if (environment != null) {

Loading…
Cancel
Save