Skip to content

Commit 0cdd3f8

Browse files
authored
Merge pull request #50636 from manovotn/issue50633
Improve error message for when websocket endpoint isn't a bean
2 parents 1a4c49d + 3d46170 commit 0cdd3f8

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

extensions/websockets-next/deployment/src/main/java/io/quarkus/websockets/next/deployment/WebSocketProcessor.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -437,19 +437,30 @@ void collectEndpoints(BeanArchiveIndexBuildItem beanArchiveIndex,
437437

438438
@BuildStep
439439
void validateConnectorInjectionPoints(List<WebSocketEndpointBuildItem> endpoints,
440+
BeanDiscoveryFinishedBuildItem beanDiscoveryFinishedBuildItem,
440441
ValidationPhaseBuildItem validationPhase, BuildProducer<ValidationErrorBuildItem> validationErrors) {
441442
for (InjectionPointInfo injectionPoint : validationPhase.getContext().getInjectionPoints()) {
442443
if (injectionPoint.getRequiredType().name().equals(WebSocketDotNames.WEB_SOCKET_CONNECTOR)
443444
&& injectionPoint.hasDefaultedQualifier()) {
444445
Type clientEndpointType = injectionPoint.getRequiredType().asParameterizedType().arguments().get(0);
445-
if (endpoints.stream()
446-
.filter(WebSocketEndpointBuildItem::isClient)
447-
.map(WebSocketEndpointBuildItem::beanClassName)
448-
.noneMatch(clientEndpointType.name()::equals)) {
446+
if (beanDiscoveryFinishedBuildItem.beanStream().withBeanClass(clientEndpointType.name()).isEmpty()) {
447+
// there is no CDI bean with given name
449448
validationErrors.produce(
450449
new ValidationErrorBuildItem(new WebSocketClientException(String.format(
451-
"Type argument [%s] of the injected WebSocketConnector is not a @WebSocketClient endpoint: %s",
450+
"Type argument [%s] of the injected WebSocketConnector is not a @WebSocketClient endpoint, because it is not a bean: %s"
451+
+ "\nPlease consult https://quarkus.io/guides/cdi-reference#bean_discovery on how to make the module containing "
452+
+ "the code discoverable by Quarkus. ",
452453
clientEndpointType, injectionPoint.getTargetInfo()))));
454+
} else {
455+
if (endpoints.stream()
456+
.filter(WebSocketEndpointBuildItem::isClient)
457+
.map(WebSocketEndpointBuildItem::beanClassName)
458+
.noneMatch(clientEndpointType.name()::equals)) {
459+
validationErrors.produce(
460+
new ValidationErrorBuildItem(new WebSocketClientException(String.format(
461+
"Type argument [%s] of the injected WebSocketConnector is not a @WebSocketClient endpoint: %s",
462+
clientEndpointType, injectionPoint.getTargetInfo()))));
463+
}
453464
}
454465
}
455466
}

0 commit comments

Comments
 (0)