dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

[Bug] Using Stream With generic and injvm not work

Open xixingya opened this issue 1 year ago • 11 comments

Pre-check

  • [X] I am sure that all the content I provide is in English.

Search before asking

  • [X] I had searched in the issues and found no similar issues.

Apache Dubbo Component

Java SDK (apache/dubbo)

Dubbo Version

3.2.*

Steps to reproduce this issue

https://github.com/xixingya/dubbo-demo/blob/master/dubbo-demo-spi/src/main/java/tech/xixing/dubbo/demo/stream/StreamProviderDemo.java
please see this code. which is copy from

https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/protocol/triple/streaming/#%E5%AE%9E%E7%8E%B0%E7%B1%BB

What you expected to happen

the stream mode not working

Anything else

No response

Are you willing to submit a pull request to fix on your own?

  • [ ] Yes I am willing to submit a pull request on my own!

Code of Conduct

xixingya avatar Aug 19 '24 07:08 xixingya

org.apache.dubbo.rpc.RpcException: java.lang.IllegalArgumentException: [Serialization Security] Serialized class tech.xixing.dubbo.demo.stream.StreamConsumerDemo$1 has not implement Serializable interface. Current mode is strict check, will disallow to deserialize it by default. at org.apache.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:129) at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:349) at org.apache.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:54) at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:349) at org.apache.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:41)

at org.apache.dubbo.rpc.TriRpcStatus.asException(TriRpcStatus.java:213)
at org.apache.dubbo.rpc.protocol.tri.call.UnaryClientCallListener.onClose(UnaryClientCallListener.java:53)
at org.apache.dubbo.rpc.protocol.tri.call.TripleClientCall.onComplete(TripleClientCall.java:127)
at org.apache.dubbo.rpc.protocol.tri.stream.TripleClientStream$ClientTransportListener.finishProcess(TripleClientStream.java:243)
at org.apache.dubbo.rpc.protocol.tri.stream.TripleClientStream$ClientTransportListener.onTrailersReceived(TripleClientStream.java:328)
at org.apache.dubbo.rpc.protocol.tri.stream.TripleClientStream$ClientTransportListener.lambda$onHeader$1(TripleClientStream.java:431)
at org.apache.dubbo.common.threadpool.serial.SerializingExecutor.run(SerializingExecutor.java:105)

xixingya avatar Aug 19 '24 08:08 xixingya

System.setProperty("dubbo.application.check-serializable", "false"); must set this properties works well,But using stream mode why I should set this properties

xixingya avatar Aug 19 '24 09:08 xixingya

because your stream consumer demo application invoke with generic,

image

but stream pattern can't either use generic or two params

image

you should remove reference.setGeneric("true"); than try again

JunJieLiu51520 avatar Aug 19 '24 17:08 JunJieLiu51520

do you have some idea for your case ? i can implement that @xixingya

JunJieLiu51520 avatar Aug 19 '24 17:08 JunJieLiu51520

do you have some idea for your case ? i can implement that @xixingya

maybe streamObserver can exclude by Serializable check?

xixingya avatar Aug 20 '24 02:08 xixingya

StreamObserver is a special class and should not pass to Serialize checker

AlbumenJ avatar Aug 21 '24 02:08 AlbumenJ

StreamObserver is a special class and should not pass to Serialize checker

i guess that he wants to use generic invoke, and at the same time use StreamObserver(BI or S),such as following case:

    // generic invoke
    GenericService genericService = bootstrap.getCache().get(reference);

    StreamObserver<String> responseObserver = new StreamObserver<String>() {
        @Override
        public void onNext(String data) {
            
        }

        @Override
        public void onError(Throwable throwable) {

        }

        @Override
        public void onCompleted() {

        }
    };

    while (true) {
        try {
            Object genericInvokeResult =
                    genericService.$invoke("sayHello",
                            new String[] {String.class.getName(),StreamObserver.class.getName()},
                            new Object[] {param,responseObserver});
            System.out.println(genericInvokeResult);
            Thread.sleep(1000);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

is it ? @xixingya

JunJieLiu51520 avatar Aug 21 '24 03:08 JunJieLiu51520

StreamObserver is a special class and should not pass to Serialize checker

yesterday, i try to rebuild GenericFilter and TripleInvoker to support it, but it's costly, need i support it ? @AlbumenJ

JunJieLiu51520 avatar Aug 21 '24 03:08 JunJieLiu51520

You can try it

AlbumenJ avatar Aug 22 '24 01:08 AlbumenJ

same promblem, looking forword to a solution~~

shijilin0116 avatar Aug 30 '24 07:08 shijilin0116

// generic invoke
GenericService genericService = bootstrap.getCache().get(reference);

StreamObserver<String> responseObserver = new StreamObserver<String>() {
    @Override
    public void onNext(String data) {
        
    }

    @Override
    public void onError(Throwable throwable) {

    }

    @Override
    public void onCompleted() {

    }
};

while (true) {
    try {
        Object genericInvokeResult =
                genericService.$invoke("sayHello",
                        new String[] {String.class.getName(),StreamObserver.class.getName()},
                        new Object[] {param,responseObserver});
        System.out.println(genericInvokeResult);
        Thread.sleep(1000);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

@JunJieLiu51520 I have this requirement, how can it be implemented?

flyhawk1010 avatar Sep 11 '24 03:09 flyhawk1010