Skip to content

Commit 74ac1dd

Browse files
manovotngsmet
authored andcommitted
Fix InjectionPointModifier for repeated annotations on method parameters; add grpc test
(cherry picked from commit 8ce8779)
1 parent 2666994 commit 74ac1dd

File tree

2 files changed

+62
-9
lines changed

2 files changed

+62
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package io.quarkus.grpc.client.interceptors;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
import static org.junit.jupiter.api.Assertions.assertEquals;
5+
6+
import java.util.List;
7+
8+
import org.jboss.shrinkwrap.api.ShrinkWrap;
9+
import org.jboss.shrinkwrap.api.spec.JavaArchive;
10+
import org.junit.jupiter.api.Test;
11+
import org.junit.jupiter.api.extension.RegisterExtension;
12+
import org.slf4j.Logger;
13+
import org.slf4j.LoggerFactory;
14+
15+
import io.grpc.examples.helloworld.Greeter;
16+
import io.grpc.examples.helloworld.GreeterBean;
17+
import io.grpc.examples.helloworld.GreeterGrpc;
18+
import io.grpc.examples.helloworld.HelloReply;
19+
import io.grpc.examples.helloworld.HelloReplyOrBuilder;
20+
import io.grpc.examples.helloworld.HelloRequest;
21+
import io.grpc.examples.helloworld.HelloRequestOrBuilder;
22+
import io.grpc.examples.helloworld.MutinyGreeterGrpc;
23+
import io.quarkus.grpc.GrpcClient;
24+
import io.quarkus.grpc.RegisterClientInterceptor;
25+
import io.quarkus.grpc.server.services.MutinyHelloService;
26+
import io.quarkus.test.QuarkusUnitTest;
27+
28+
public class ClientInterceptorConstructorRegistrationTest {
29+
30+
@RegisterExtension
31+
static final QuarkusUnitTest config = new QuarkusUnitTest().setArchiveProducer(
32+
() -> ShrinkWrap.create(JavaArchive.class)
33+
.addClasses(MutinyHelloService.class, MyThirdClientInterceptor.class, MyLastClientInterceptor.class,
34+
Calls.class,
35+
GreeterGrpc.class, Greeter.class, GreeterBean.class, HelloRequest.class, HelloReply.class,
36+
MutinyGreeterGrpc.class,
37+
HelloRequestOrBuilder.class, HelloReplyOrBuilder.class))
38+
.withConfigurationResource("hello-config.properties");
39+
private static final Logger log = LoggerFactory.getLogger(ClientInterceptorConstructorRegistrationTest.class);
40+
41+
private GreeterGrpc.GreeterBlockingStub client;
42+
43+
public ClientInterceptorConstructorRegistrationTest(
44+
@RegisterClientInterceptor(MyLastClientInterceptor.class) @RegisterClientInterceptor(MyThirdClientInterceptor.class) @GrpcClient("hello-service") GreeterGrpc.GreeterBlockingStub client) {
45+
this.client = client;
46+
}
47+
48+
@Test
49+
public void testInterceptorRegistration() {
50+
Calls.LIST.clear();
51+
52+
HelloReply reply = client
53+
.sayHello(HelloRequest.newBuilder().setName("neo").build());
54+
assertThat(reply.getMessage()).isEqualTo("Hello neo");
55+
56+
List<String> calls = Calls.LIST;
57+
assertEquals(2, calls.size());
58+
assertEquals(MyThirdClientInterceptor.class.getName(), calls.get(0));
59+
assertEquals(MyLastClientInterceptor.class.getName(), calls.get(1));
60+
}
61+
}

independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/InjectionPointModifier.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.util.HashSet;
44
import java.util.List;
55
import java.util.Set;
6-
import java.util.stream.Collectors;
76

87
import org.jboss.jandex.AnnotationInstance;
98
import org.jboss.jandex.AnnotationTarget;
@@ -42,14 +41,7 @@ public Set<AnnotationInstance> applyTransformers(Type type, AnnotationTarget tar
4241
transformer.transform(transformationContext);
4342
}
4443
}
45-
if (methodParameterTarget != null && AnnotationTarget.Kind.METHOD_PARAMETER.equals(methodParameterTarget.kind())) {
46-
// only return set of qualifiers related to the given method parameter
47-
return transformationContext.getQualifiers().stream().filter(
48-
annotationInstance -> methodParameterTarget.equals(annotationInstance.target()))
49-
.collect(Collectors.toSet());
50-
} else {
51-
return transformationContext.getQualifiers();
52-
}
44+
return transformationContext.getQualifiers();
5345
}
5446

5547
// method variant used for field and resource field injection; a case where we don't need to deal with method. params

0 commit comments

Comments
 (0)