Skip to content

Commit 65382a9

Browse files
committed
Add more nullability annotations to core/spring-boot
See gh-46587
1 parent edc4c9e commit 65382a9

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

core/spring-boot/src/main/java/org/springframework/boot/ApplicationContextFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public interface ApplicationContextFactory {
7676
* @param webApplicationType the web application type
7777
* @return the newly created application context
7878
*/
79-
ConfigurableApplicationContext create(@Nullable WebApplicationType webApplicationType);
79+
@Nullable ConfigurableApplicationContext create(@Nullable WebApplicationType webApplicationType);
8080

8181
/**
8282
* Creates an {@code ApplicationContextFactory} that will create contexts by

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,10 @@ protected void bindToSpringApplication(ConfigurableEnvironment environment) {
569569
* @see #setApplicationContextFactory(ApplicationContextFactory)
570570
*/
571571
protected ConfigurableApplicationContext createApplicationContext() {
572-
return this.applicationContextFactory.create(this.properties.getWebApplicationType());
572+
ConfigurableApplicationContext context = this.applicationContextFactory
573+
.create(this.properties.getWebApplicationType());
574+
Assert.state(context != null, "ApplicationContextFactory created null context");
575+
return context;
573576
}
574577

575578
/**

0 commit comments

Comments
 (0)