Skip to content

Commit 8529913

Browse files
committed
Improve error message when no ServerProperties bean is found
Closes gh-11511
1 parent cbefc7b commit 8529913

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2015 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,7 +29,6 @@
2929
import org.springframework.context.annotation.Bean;
3030
import org.springframework.context.annotation.Configuration;
3131
import org.springframework.core.Ordered;
32-
import org.springframework.util.Assert;
3332
import org.springframework.util.StringUtils;
3433

3534
/**
@@ -81,9 +80,14 @@ public void customize(ConfigurableEmbeddedServletContainer container) {
8180
// a single bean
8281
String[] serverPropertiesBeans = this.applicationContext
8382
.getBeanNamesForType(ServerProperties.class);
84-
Assert.state(serverPropertiesBeans.length == 1,
85-
"Multiple ServerProperties beans registered " + StringUtils
86-
.arrayToCommaDelimitedString(serverPropertiesBeans));
83+
if (serverPropertiesBeans.length == 0) {
84+
throw new IllegalStateException("No ServerProperties bean registered");
85+
}
86+
if (serverPropertiesBeans.length > 1) {
87+
throw new IllegalStateException(
88+
"Multiple ServerProperties beans registered " + StringUtils
89+
.arrayToCommaDelimitedString(serverPropertiesBeans));
90+
}
8791
}
8892

8993
}

0 commit comments

Comments
 (0)