Improve health contributor null support

Update `NamedContributorsMapAdapter` to check for `null` keys or values
during construction. Also update `HealthEndpointSupport` to allow
null component entries.

See gh-18687
This commit is contained in:
Phillip Webb
2019-10-23 13:05:01 -07:00
parent 7c9ac03014
commit ba30ee03df
3 changed files with 25 additions and 2 deletions

View File

@@ -48,6 +48,22 @@ class NamedContributorsMapAdapterTests {
.withMessage("ValueAdapter must not be null");
}
@Test
void createWhenMapContainsNullValueThrowsException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new TestNamedContributorsMapAdapter<>(Collections.singletonMap("test", null),
Function.identity()))
.withMessage("Map must not contain null values");
}
@Test
void createWhenMapContainsNullKeyThrowsException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new TestNamedContributorsMapAdapter<>(Collections.singletonMap(null, "test"),
Function.identity()))
.withMessage("Map must not contain null keys");
}
@Test
void iterateReturnsAdaptedEntries() {
TestNamedContributorsMapAdapter<String> adapter = createAdapter();