diff --git a/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/EventBusCodecProcessor.java b/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/EventBusCodecProcessor.java index 1b6c049760a64..3d2aba17cccdf 100644 --- a/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/EventBusCodecProcessor.java +++ b/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/EventBusCodecProcessor.java @@ -42,7 +42,7 @@ public void registerCodecs( final IndexView index = beanArchiveIndexBuildItem.getIndex(); Collection consumeEventAnnotationInstances = index.getAnnotations(CONSUME_EVENT); - Map codecByTypes = new HashMap<>(); + Map codecByTypes = new HashMap<>(); for (AnnotationInstance consumeEventAnnotationInstance : consumeEventAnnotationInstances) { AnnotationTarget typeTarget = consumeEventAnnotationInstance.target(); if (typeTarget.kind() != AnnotationTarget.Kind.METHOD) { @@ -59,7 +59,7 @@ public void registerCodecs( if (codecTargetFromParameter == null) { throw new IllegalStateException("Invalid `codec` argument in @ConsumeEvent - no parameter"); } - codecByTypes.put(codecTargetFromParameter, codec.asClass().asClassType().name()); + codecByTypes.put(codecTargetFromParameter.name(), codec.asClass().asClassType().name()); } else if (codecTargetFromParameter != null) { // Codec is not set, check if we have a built-in codec if (!hasBuiltInCodec(codecTargetFromParameter)) { @@ -70,24 +70,24 @@ public void registerCodecs( "The generic message codec can only be used for local delivery," + ", implement your own event bus codec for " + codecTargetFromParameter.name() .toString()); - } else if (!codecByTypes.containsKey(codecTargetFromParameter)) { + } else if (!codecByTypes.containsKey(codecTargetFromParameter.name())) { LOGGER.infof("Local Message Codec registered for type %s", codecTargetFromParameter.toString()); - codecByTypes.put(codecTargetFromParameter, LOCAL_EVENT_BUS_CODEC); + codecByTypes.put(codecTargetFromParameter.name(), LOCAL_EVENT_BUS_CODEC); } } } if (codecTargetFromReturnType != null && !hasBuiltInCodec(codecTargetFromReturnType) - && !codecByTypes.containsKey(codecTargetFromReturnType)) { + && !codecByTypes.containsKey(codecTargetFromReturnType.name())) { LOGGER.infof("Local Message Codec registered for type %s", codecTargetFromReturnType.toString()); - codecByTypes.put(codecTargetFromReturnType, LOCAL_EVENT_BUS_CODEC); + codecByTypes.put(codecTargetFromReturnType.name(), LOCAL_EVENT_BUS_CODEC); } } // Produce the build items - for (Map.Entry entry : codecByTypes.entrySet()) { + for (Map.Entry entry : codecByTypes.entrySet()) { messageCodecs.produce(new MessageCodecBuildItem(entry.getKey().toString(), entry.getValue().toString())); } diff --git a/extensions/vertx/deployment/src/test/java/io/quarkus/vertx/EventBusCodecTest.java b/extensions/vertx/deployment/src/test/java/io/quarkus/vertx/EventBusCodecTest.java index 3bb61dd42ea6f..26cbd3a1ea86a 100644 --- a/extensions/vertx/deployment/src/test/java/io/quarkus/vertx/EventBusCodecTest.java +++ b/extensions/vertx/deployment/src/test/java/io/quarkus/vertx/EventBusCodecTest.java @@ -2,6 +2,10 @@ import static org.assertj.core.api.Assertions.assertThat; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; @@ -73,6 +77,11 @@ String getMessage() { } } + @Retention(RetentionPolicy.CLASS) + @Target(ElementType.TYPE_USE) + @interface NonNull { + } + static class MyBean { @ConsumeEvent("person") public CompletionStage hello(Person p) { @@ -83,6 +92,12 @@ public CompletionStage hello(Person p) { public CompletionStage hello(Pet p) { return CompletableFuture.completedFuture(new Greeting("Hello " + p.getName())); } + + // presence of this method is enough to verify that type annotation + // on the message type doesn't cause failure + @ConsumeEvent("message-type-with-type-annotation") + void messageTypeWithTypeAnnotation(@NonNull Person person) { + } } static class MyNonLocalBean {