question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't use GlobalInterceptor gRPC annotation with interceptor produced by a method

See original GitHub issue

Describe the bug

I have a server interceptor produced by a method:

  @Produces
  public ServerInterceptor serverInterceptor() {
    return new LoggingServerInterceptor();
  }

I want to make it global by putting io.quarkus.grpc.GlobalInterceptor annotation.

I can’t put this annotation on the producer method, because the annotation has @Target({ FIELD, PARAMETER, TYPE }) (not applicable to methods).

And I can’t put this annotation on LoggingServerInterceptor class, because the class does not have any CDI bean annotations on it. Quarkus complains:

2021-11-11 04:23:49,640 ERROR [io.qua.grp.run.GrpcServerRecorder] (main) Unable to start the gRPC server: java.lang.IllegalArgumentException: Server interceptor class class com.azul.cc.infrastructure.grpc.LoggingServerInterceptor is not a CDI bean. Only CDI beans can be used as gRPC server interceptors. Add one of the scope-defining annotations (@Singleton, @ApplicationScoped, @RequestScoped) on the interceptor class.

Expected behavior

The GlobalInterceptor annotation should support this case as well.

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.4.1.Final

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
michalszynkiewiczcommented, Nov 17, 2021

I understand it’s more convenient in some cases, I’m not closing this issue. What I wanted to say is that, having a work around, and being non-trivial, I don’t consider this a high priority feature request.

0reactions
slinkydevelopercommented, Sep 19, 2022

I stumbled on this issue and I was wondering, would it be possible to use the Produces annotation at least for service scoped interceptors? It would be nice to reuse existing interceptors without wrapping them in new classes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - How to add global exception interceptor in gRPC server?
To install an interceptor for all services on a server, you can use ServerBuilder.intercept() , which was added in gRPC 1.5.0.
Read more >
Implementing a gRPC Service - Quarkus
To apply an interceptor to all exposed services, annotate it with @io.quarkus.grpc.GlobalInterceptor . To apply an interceptor to a single service, register it ......
Read more >
Configuration | grpc-spring-boot-starter - GitHub Pages
Define the ClientInterceptor as a global interceptor using either the @GrpcGlobalClientInterceptor annotation, or a GlobalClientInterceptorConfigurer ...
Read more >
Interceptors in gRPC-Web
Stream interceptor example · Create a ClientReadableStream -wrapper class, and use it to intercept stream events such as the reception of server ...
Read more >
Interceptors | NestJS - A progressive Node.js framework
An interceptor is a class annotated with the @Injectable() decorator and ... up a global interceptor, we use the useGlobalInterceptors() method of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found