Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order annotation for @GRpcGlobalInterceptor not working correctly when using 'org.springframework.boot.autoconfigure.AutoConfiguration.imports' #383

Open
rafal-dudek opened this issue Oct 9, 2023 · 0 comments

Comments

@rafal-dudek
Copy link

In our internal company library, we are using file resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports to declare Configurations which should be active for applications using it - similar to many other Spring Boot libraries.

In this configuration Order for ServerInterceptor with annotation @GRpcGlobalInterceptor is not working.

The problem is probably related to the fact, that with that configuration Spring Boot is using ASM-based classreader resulting with
SimpleMethodMetadata instead of reflection classreader with StandardMethodMetadata.

With such configuration Order for different Interceptors e.g. OncePerRequestFilter and WebFilter works correctly, but for GRpcGlobalInterceptor is not.

How to reproduce:
Modify your test grpc-spring-boot-starter-demo\src\test\java\org\lognet\springboot\grpc\OrderedInterceptorsTest.java which is working on Import.

  1. Remove TheConfiguration.class from SpringBootTest to disable manual Import:
@SpringBootTest(classes = {DemoApp.class},
        webEnvironment = WebEnvironment.NONE, properties = {"grpc.port=7778", "grpc.shutdownGrace=-1"})

Now result should be:

Expecting actual:
  []
to contain exactly (and in same order):
  [1, 2, 3, 4, 5, 6, 7, 8, 10, 10, 100, 100]
  1. Add file grpc-spring-boot-starter-demo\src\test\resources\META-INF\spring\org.springframework.boot.autoconfigure.AutoConfiguration.imports with content:
    org.lognet.springboot.grpc.OrderedInterceptorsTest.TheConfiguration to enable AutoConfiguration.

Result of the test - Order annotation is not working correctly:

Expecting actual:
  [1, 2, 3, 4, 5, 6, 10, 10, 8, 100, 7, 100]
to contain exactly (and in same order):
  [1, 2, 3, 4, 5, 6, 7, 8, 10, 10, 100, 100]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant