Improve exception message if endpoint can't be found
This commit is contained in:
parent
ed9169501e
commit
4ea3c75331
|
@ -103,7 +103,8 @@ class JerseyWebEndpointManagementContextConfiguration {
|
|||
ExposableWebEndpoint health = webEndpoints.stream()
|
||||
.filter((endpoint) -> endpoint.getEndpointId().equals(HEALTH_ENDPOINT_ID))
|
||||
.findFirst()
|
||||
.get();
|
||||
.orElseThrow(
|
||||
() -> new IllegalStateException("No endpoint with id '%s' found".formatted(HEALTH_ENDPOINT_ID)));
|
||||
return new JerseyAdditionalHealthEndpointPathsManagementResourcesRegistrar(health, healthEndpointGroups);
|
||||
}
|
||||
|
||||
|
|
|
@ -120,7 +120,8 @@ public class WebFluxEndpointManagementContextConfiguration {
|
|||
ExposableWebEndpoint health = webEndpoints.stream()
|
||||
.filter((endpoint) -> endpoint.getEndpointId().equals(HealthEndpoint.ID))
|
||||
.findFirst()
|
||||
.get();
|
||||
.orElseThrow(
|
||||
() -> new IllegalStateException("No endpoint with id '%s' found".formatted(HealthEndpoint.ID)));
|
||||
return new AdditionalHealthEndpointPathsWebFluxHandlerMapping(new EndpointMapping(""), health,
|
||||
groups.getAllWithAdditionalPath(WebServerNamespace.MANAGEMENT));
|
||||
}
|
||||
|
@ -162,16 +163,16 @@ public class WebFluxEndpointManagementContextConfiguration {
|
|||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (bean instanceof ServerCodecConfigurer) {
|
||||
process((ServerCodecConfigurer) bean);
|
||||
if (bean instanceof ServerCodecConfigurer serverCodecConfigurer) {
|
||||
process(serverCodecConfigurer);
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
private void process(ServerCodecConfigurer configurer) {
|
||||
for (HttpMessageWriter<?> writer : configurer.getWriters()) {
|
||||
if (writer instanceof EncoderHttpMessageWriter) {
|
||||
process(((EncoderHttpMessageWriter<?>) writer).getEncoder());
|
||||
if (writer instanceof EncoderHttpMessageWriter<?> encoderHttpMessageWriter) {
|
||||
process((encoderHttpMessageWriter).getEncoder());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,7 +115,8 @@ public class WebMvcEndpointManagementContextConfiguration {
|
|||
ExposableWebEndpoint health = webEndpoints.stream()
|
||||
.filter((endpoint) -> endpoint.getEndpointId().equals(HealthEndpoint.ID))
|
||||
.findFirst()
|
||||
.get();
|
||||
.orElseThrow(
|
||||
() -> new IllegalStateException("No endpoint with id '%s' found".formatted(HealthEndpoint.ID)));
|
||||
return new AdditionalHealthEndpointPathsWebMvcHandlerMapping(health,
|
||||
groups.getAllWithAdditionalPath(WebServerNamespace.MANAGEMENT));
|
||||
}
|
||||
|
@ -157,8 +158,8 @@ public class WebMvcEndpointManagementContextConfiguration {
|
|||
@Override
|
||||
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||
for (HttpMessageConverter<?> converter : converters) {
|
||||
if (converter instanceof MappingJackson2HttpMessageConverter) {
|
||||
configure((MappingJackson2HttpMessageConverter) converter);
|
||||
if (converter instanceof MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter) {
|
||||
configure(mappingJackson2HttpMessageConverter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,8 @@ class HealthEndpointReactiveWebExtensionConfiguration {
|
|||
ExposableWebEndpoint health = webEndpoints.stream()
|
||||
.filter((endpoint) -> endpoint.getEndpointId().equals(HealthEndpoint.ID))
|
||||
.findFirst()
|
||||
.get();
|
||||
.orElseThrow(
|
||||
() -> new IllegalStateException("No endpoint with id '%s' found".formatted(HealthEndpoint.ID)));
|
||||
return new AdditionalHealthEndpointPathsWebFluxHandlerMapping(new EndpointMapping(""), health,
|
||||
groups.getAllWithAdditionalPath(WebServerNamespace.SERVER));
|
||||
}
|
||||
|
|
|
@ -81,7 +81,8 @@ class HealthEndpointWebExtensionConfiguration {
|
|||
return webEndpoints.stream()
|
||||
.filter((endpoint) -> endpoint.getEndpointId().equals(HealthEndpoint.ID))
|
||||
.findFirst()
|
||||
.get();
|
||||
.orElseThrow(
|
||||
() -> new IllegalStateException("No endpoint with id '%s' found".formatted(HealthEndpoint.ID)));
|
||||
}
|
||||
|
||||
@ConditionalOnBean(DispatcherServlet.class)
|
||||
|
|
Loading…
Reference in New Issue