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