Skip to content
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

Caused by: java.lang.RuntimeException: Serialized class com.alibaba.csp.sentinel.slots.block.flow.FlowRule must implement java.io.Serializable #1065

Closed
tcxurun opened this issue Sep 24, 2019 · 6 comments · Fixed by #1794
Labels
area/integrations Issues or PRs related to integrations with open-source components kind/question Category issues related to questions or problems
Milestone

Comments

@tcxurun
Copy link

tcxurun commented Sep 24, 2019

采用Dubbo集成Sentinel,资源是在Provider端,Consumer端调用,限流后进行压测报这个错误
Caused by: com.alibaba.dubbo.remoting.RemotingException: Failed to send response: Response [id=1338, version=2.0.0, status=20, event=false, error=null, result=RpcResult [result=null, exception=java.lang.reflect.UndeclaredThrowableException]], cause: java.lang.RuntimeException: Serialized class com.alibaba.csp.sentinel.slots.block.flow.FlowRule must implement java.io.Serializable
Java field: protected com.alibaba.csp.sentinel.slots.block.AbstractRule com.alibaba.csp.sentinel.slots.block.BlockException.rule
Java field: private java.lang.Throwable java.lang.reflect.UndeclaredThrowableException.undeclaredThrowable
java.lang.RuntimeException: Serialized class com.alibaba.csp.sentinel.slots.block.flow.FlowRule must implement java.io.Serializable
Java field: protected com.alibaba.csp.sentinel.slots.block.AbstractRule com.alibaba.csp.sentinel.slots.block.BlockException.rule
Java field: private java.lang.Throwable java.lang.reflect.UndeclaredThrowableException.undeclaredThrowable

@sentinel-bot
Copy link
Collaborator

Hi @tcxurun, we detect non-English characters in the issue. This comment is an auto translation from @sentinel-bot to help other users to understand this issue.
We encourage you to describe your issue in English which is more friendly to other users.

Caused by: java.lang.RuntimeException: Serialized class com.alibaba.csp.sentinel.slots.block.flow.FlowRule must implement java.io.Serializable

Using Dubbo to integrate Sentinel, the resource is on the Provider side, the Consumer side is called, and the error is reported after the current limit is reported.
Caused by: com.alibaba.dubbo.remoting.RemotingException: Failed to send response: Response [id=1338, version=2.0.0, status=20, event=false, error=null, result=RpcResult [result=null, exception=java.lang.reflect.UndeclaredThrowableException]], cause: java.lang.RuntimeException: Serialized class com.alibaba.csp.sentinel.slots.block.flow.FlowRule must implement java.io.Serializable
Java field: protected com.alibaba.csp.sentinel.slots.block.AbstractRule com.alibaba.csp.sentinel.slots.block.BlockException.rule
Java field: private java.lang.Throwable java.lang.reflect.UndeclaredThrowableException.undeclaredThrowable
java.lang.RuntimeException: Serialized class com.alibaba.csp.sentinel.slots.block.flow.FlowRule must implement java.io.Serializable
Java field: protected com.alibaba.csp.sentinel.slots.block.AbstractRule com.alibaba.csp.sentinel.slots.block.BlockException.rule
Java field: private java.lang.Throwable java.lang.reflect.UndeclaredThrowableException.undeclaredThrowable

@jasonjoo2010
Copy link
Collaborator

The root cause is the provider didn't deal with the BlockException while BlockException is not designed to be transmitted in RPC environment.

If you want to customize the fallback in provider side you can use DubboFallbackRegistry. setProviderFallback().

This issue is related to #1017

@wzg923
Copy link
Contributor

wzg923 commented Sep 23, 2020

Describe problem:
com.alibaba:dubbo:2.6.9
com.alibaba.csp:sentinel-dubbo-adapter:1.8.0
problem code

com.alibaba.csp.sentinel.adapter.dubbo.fallback.DefaultDubboFallback
public class DefaultDubboFallback implements DubboFallback {
    @Override
    public Result handle(Invoker<?> invoker, Invocation invocation, BlockException ex) {
        // Just wrap and throw the exception.
        throw new SentinelRpcException(ex);
    }
}

should change to :

public class DefaultDubboFallback implements DubboFallback {

    @Override
    public Result handle(Invoker<?> invoker, Invocation invocation, BlockException ex) {
        // Just wrap the exception.
        RpcResult result = new RpcResult();
        result.setException(ex.toRuntimeException());
        return result;
    }
}

@sczyh30
Copy link
Member

sczyh30 commented Sep 23, 2020

@wzg923 Would you like to submit a PR to fix it?

@wzg923
Copy link
Contributor

wzg923 commented Sep 23, 2020

@wzg923 Would you like to submit a PR to fix it?

It's my pleasure, but I don't have the permission to push or create a new git branch

@sczyh30
Copy link
Member

sczyh30 commented Sep 23, 2020

@wzg923 Would you like to submit a PR to fix it?

It's my pleasure, but I don't have the permission to push or create a new git branch

You may refer to https://github.com/alibaba/Sentinel/wiki/开源贡献指南

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment