Description
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.
- 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]
- 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]