You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "icodening (via GitHub)" <gi...@apache.org> on 2023/03/07 15:56:49 UTC

[GitHub] [dubbo] icodening opened a new issue, #11762: [Bug]triple协议的Stub和Proxy的行为不一致

icodening opened a new issue, #11762:
URL: https://github.com/apache/dubbo/issues/11762

   # 原因
   Stub方式调用方法时并非通过反射调用,而是包装成了一个`Function`的直接调用;
   而Proxy方式调用时则是通过`method.invoke`的方式进行反射调用,反射调用时报错会抛出`InvocationTargetException`,在`org.apache.dubbo.rpc.proxy.AbstractProxyInvoker`的117行处捕获,并返回了一个带有异常的`AsyncRpcResult`
   
   服务端业务代码案例如下:
   ````java
   public StreamObserver<Long> userStream(StreamObserver<User> responseObserver) {
       System.out.println(1 / 0);//直接抛出异常
       return new StreamObserver<Long>() {
           @Override
           public void onNext(Long id) {
               responseObserver.onNext(getUser(id));
           }
   
           @Override
           public void onError(Throwable throwable) {
               System.out.println("onError");
               responseObserver.onError(throwable);
           }
   
           @Override
           public void onCompleted() {
               System.out.println("onCompleted");
               responseObserver.onCompleted();
           }
       };
   }
   ````
   如图所示,没有按照预期调用`responseObserver.onError(e);` 而是把它当成了正常的返回值调用了`onReturn`
   <img width="1687" alt="image" src="https://user-images.githubusercontent.com/42876375/223472065-1b7cd6ec-43f9-47f0-bb3c-b15c221f74c3.png">
   
   然后此处的`ClassCastException`发生在CompletableFuture里,后续没有处理将被忽略
   <img width="1150" alt="image" src="https://user-images.githubusercontent.com/42876375/223472201-dd0ac89e-a2d2-466b-a5a2-76569fdf1140.png">
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] liufeiyu1002 commented on issue #11762: [Bug]triple协议的Stub和Proxy的行为不一致

Posted by "liufeiyu1002 (via GitHub)" <gi...@apache.org>.
liufeiyu1002 commented on issue #11762:
URL: https://github.com/apache/dubbo/issues/11762#issuecomment-1459940617

   这个应该是  [10667](https://github.com/apache/dubbo/pull/10667/files) 支持tri 自定义返回异常的时候 只考虑了 UNARY 正常调用时处理异常,  没有考虑 stream 返回时类型的问题 导致的 
   ![image](https://user-images.githubusercontent.com/32605119/223686458-99638461-f8bd-49f3-ba2e-53799e58f800.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] EarthChen closed issue #11762: [Bug]triple协议的Stub和Proxy的行为不一致

Posted by "EarthChen (via GitHub)" <gi...@apache.org>.
EarthChen closed issue #11762: [Bug]triple协议的Stub和Proxy的行为不一致
URL: https://github.com/apache/dubbo/issues/11762


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org