-
Notifications
You must be signed in to change notification settings - Fork 434
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
add gRPC exception advice support for factory beans #266
base: master
Are you sure you want to change the base?
add gRPC exception advice support for factory beans #266
Conversation
...r/src/main/java/org/lognet/springboot/grpc/autoconfigure/OnMissingErrorHandlerCondition.java
Outdated
Show resolved
Hide resolved
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #266 +/- ##
============================================
- Coverage 88.24% 88.09% -0.15%
- Complexity 317 318 +1
============================================
Files 50 50
Lines 1531 1537 +6
Branches 86 87 +1
============================================
+ Hits 1351 1354 +3
- Misses 143 144 +1
- Partials 37 39 +2 ☔ View full report in Codecov by Sentry. |
I will add tests for this. |
what is the spring boot version you are running with? |
@jvmlet 2.5.6 |
@jvmlet any recommendations on how I can get the code coverage to pass? I checked https://app.codecov.io/gh/LogNet/grpc-spring-boot-starter/compare/266/changes and it seems to have no changes and I also added tests to ensure the bean loading works correctly but it complains about +0.15% coverage decrease. |
@@ -40,11 +40,23 @@ sourceSets.configureEach{s-> | |||
|
|||
protobuf { | |||
protoc { | |||
artifact = "com.google.protobuf:protoc:${grpcSpringBoot.protocVersion.get()}" | |||
|
|||
// for apple m1, please add protoc_platform=osx-x86_64 in $HOME/.gradle/gradle.properties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Apple M1 this project currently does not build due to missing artifacts. This is a recommended workaround. I can remove this again if you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a workaround and should not be needed as a property of this Spring boot starter. In case we still want to have it I'd suggest to make it as part of another pull request.
In the meantime, I will revert these changes to the grpc-spring-boot.gradle
file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is not starter's feature, but gradle plugin's one. You can have this logic in extension class and grpc-spring-boot.gradle
in separate PR.
I did some digging why that newly added code is not called during the integration tests. Here is my summary. Feedback welcome on how we could change these tests to reproduce this behaviour, as I am currently unable to determine what specifically is causing this behaviour to occur. Scenario 1: AnnotatedGenericBeanDefinitionThis is the current logic within the unit tests of this Spring Boot starter. Setting up the bean like this: Line 77 in 860950d
...will internally create an Scenario 2: ConfigurationClassBeanDefinitionReader$ConfigurationClassBeanDefinitionWithin our codebase, we use a custom Spring Boot starter to define a custom advice like so: @Bean
public GrpcExceptionAdvice grpcExceptionAdvice() {
return new GrpcExceptionAdvice();
} which itself looks like this: @GRpcServiceAdvice
public class GrpcExceptionAdvice {
/* exception handlers go here*/
} This is literally the same setup, however, for some reason it is using a different bean definition where Question time!How can I change the tests within this Spring Boot starter to replicate Scenario 2? |
See behavior difference if you define the inner advice class as static/non-static |
This pull request addresses #265
When currently using
@GRpcServiceAdvice
on a bean that is being created within a@Configuration
like so (Spring Boot 2.5.6):it will produce the following exception on startup:
The reason is that the current logic does not support beans created through factory methods:
grpc-spring-boot-starter/grpc-spring-boot-starter/src/main/java/org/lognet/springboot/grpc/autoconfigure/OnMissingErrorHandlerCondition.java
Line 29 in 19fc751
The solution
MethodMetadata
.