Polish SpringApplication

See gh-42606
This commit is contained in:
SangYong
2024-10-13 14:43:29 +09:00
committed by Moritz Halbritter
parent 957e2f8b7f
commit 975a3aacd6

View File

@@ -365,16 +365,13 @@ public class SpringApplication {
}
private Class<? extends ConfigurableEnvironment> deduceEnvironmentClass() {
WebApplicationType webApplicationType = this.properties.getWebApplicationType();
Class<? extends ConfigurableEnvironment> environmentType = this.applicationContextFactory
.getEnvironmentType(this.properties.getWebApplicationType());
.getEnvironmentType(webApplicationType);
if (environmentType == null && this.applicationContextFactory != ApplicationContextFactory.DEFAULT) {
environmentType = ApplicationContextFactory.DEFAULT
.getEnvironmentType(this.properties.getWebApplicationType());
environmentType = ApplicationContextFactory.DEFAULT.getEnvironmentType(webApplicationType);
}
if (environmentType == null) {
return ApplicationEnvironment.class;
}
return environmentType;
return (environmentType != null) ? environmentType : ApplicationEnvironment.class;
}
private void prepareContext(DefaultBootstrapContext bootstrapContext, ConfigurableApplicationContext context,
@@ -473,10 +470,10 @@ public class SpringApplication {
if (this.environment != null) {
return this.environment;
}
ConfigurableEnvironment environment = this.applicationContextFactory
.createEnvironment(this.properties.getWebApplicationType());
WebApplicationType webApplicationType = this.properties.getWebApplicationType();
ConfigurableEnvironment environment = this.applicationContextFactory.createEnvironment(webApplicationType);
if (environment == null && this.applicationContextFactory != ApplicationContextFactory.DEFAULT) {
environment = ApplicationContextFactory.DEFAULT.createEnvironment(this.properties.getWebApplicationType());
environment = ApplicationContextFactory.DEFAULT.createEnvironment(webApplicationType);
}
return (environment != null) ? environment : new ApplicationEnvironment();
}