Skip to content

Commit 975a3aa

Browse files
gkdis6mhalbritter
authored andcommitted
Polish SpringApplication
See gh-42606
1 parent 957e2f8 commit 975a3aa

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -365,16 +365,13 @@ private ConfigurableEnvironment prepareEnvironment(SpringApplicationRunListeners
365365
}
366366

367367
private Class<? extends ConfigurableEnvironment> deduceEnvironmentClass() {
368+
WebApplicationType webApplicationType = this.properties.getWebApplicationType();
368369
Class<? extends ConfigurableEnvironment> environmentType = this.applicationContextFactory
369-
.getEnvironmentType(this.properties.getWebApplicationType());
370+
.getEnvironmentType(webApplicationType);
370371
if (environmentType == null && this.applicationContextFactory != ApplicationContextFactory.DEFAULT) {
371-
environmentType = ApplicationContextFactory.DEFAULT
372-
.getEnvironmentType(this.properties.getWebApplicationType());
372+
environmentType = ApplicationContextFactory.DEFAULT.getEnvironmentType(webApplicationType);
373373
}
374-
if (environmentType == null) {
375-
return ApplicationEnvironment.class;
376-
}
377-
return environmentType;
374+
return (environmentType != null) ? environmentType : ApplicationEnvironment.class;
378375
}
379376

380377
private void prepareContext(DefaultBootstrapContext bootstrapContext, ConfigurableApplicationContext context,
@@ -473,10 +470,10 @@ private ConfigurableEnvironment getOrCreateEnvironment() {
473470
if (this.environment != null) {
474471
return this.environment;
475472
}
476-
ConfigurableEnvironment environment = this.applicationContextFactory
477-
.createEnvironment(this.properties.getWebApplicationType());
473+
WebApplicationType webApplicationType = this.properties.getWebApplicationType();
474+
ConfigurableEnvironment environment = this.applicationContextFactory.createEnvironment(webApplicationType);
478475
if (environment == null && this.applicationContextFactory != ApplicationContextFactory.DEFAULT) {
479-
environment = ApplicationContextFactory.DEFAULT.createEnvironment(this.properties.getWebApplicationType());
476+
environment = ApplicationContextFactory.DEFAULT.createEnvironment(webApplicationType);
480477
}
481478
return (environment != null) ? environment : new ApplicationEnvironment();
482479
}

0 commit comments

Comments
 (0)