scalecube / scalecube-services

Microservices library - scalecube-services is a high throughput, low latency reactive microservices library built to scale. It features: API-Gateways, service-discovery, service-load-balancing, the architecture supports plug-and-play service communication modules and features. built to provide performance and low-latency real-time stream-processing
http://scalecube.github.io/
Apache License 2.0
612 stars 106 forks source link

Fixed an error caused by Reflect.isRequestTypeServiceMessage() returning false on Publisher<ServiceMessage> #791

Closed harry-hao closed 4 years ago

harry-hao commented 4 years ago

When using dispatcher and REQUEST_CHANNEL together like follow:

  @ServiceMethod
  @RequestType(GreetingRequest.class)
  @ResponseType(GreetingResponse.class)
  Flux<ServiceMessage> bidiGreetingMessage(Publisher<ServiceMessage> requests);

When called it will have error GreetingRequest cannot be cast to ServiceMessage. The error happens at ServiceMethodInvoker::toRequest:

return methodInfo.isRequestTypeServiceMessage() ? request : request.data();

In this case, it should return request, but the isRequestTypeServiceMessage() returns false, and request.data() is returned.

This PR tries to fix this by checking the actual type arguments, then returns true.

Please take a look if this is expected behavior or should be fixed.

Thank you.