grpc-spring-boot-starter: Error interceptor does not work as expected when using R2DBC repositories
Hello,
I tried to make LogNet/grpc-spring-boot-starter
work with R2DBC Spring data repositories. Here is a minimal project that helps to reproduce the issue.
Issue: When an exception is thrown, the error interceptor (GRpcExceptionHandlerInterceptor) provided by the starter does not catch it and thus does not provide the correct error code to the client (see the readme file of my project for more details).
This is due to the way I map R2DBC results (I believe this is the right way to leverage R2DBC reactor api, isn’t it ?):
skillService.findAllSkills().map(SkillMapper::toGrpc).collectList().map(SkillMapper::toGrpcResponse)
.subscribe(responseObserver::onNext, responseObserver::onError, responseObserver::onCompleted);
Note that the interceptor “works” if I use:
responseObserver.onNext(SkillMapper.toGrpcResponse(skillService.findAllSkills()));
responseObserver.onCompleted();
With the following helper which unfortunately uses toIterable()
public final class SkillMapper {
private SkillMapper() {
}
public static ListSkills.ListSkillsResponse.Skill toGrpc(Skill skill) {
return ListSkills.ListSkillsResponse.Skill.newBuilder()
.setId(skill.getId())
.setName(skill.getName())
.setDescription(skill.getDescription())
.build();
}
public static ListSkills.ListSkillsResponse toGrpcResponse(Flux<Skill> skills) {
return ListSkills.ListSkillsResponse.newBuilder()
.addAllSkills(skills.map(skill -> toGrpc(skill)).toIterable())
.build();
}
}
but I believe this is not the right way if I want to “really be reactive”.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 23
@vincentditlevinz ,
5.1.1
is outHello @jvmlet. I’ve upgraded to 5.1.1-SNAPSHOT, and I confirm, it fixes the issue ! Well done and thanks a lot for your time 👍