<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have searched the <a href="https://github.com/apache/incubator-dubbo/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have checked the <a href="https://github.com/apache/incubator-dubbo/blob/master/FAQ.md">FAQ</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>Dubbo version: 2.6.5</li>
<li>Operating System version: macOS</li>
<li>Java version: 1.8</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<ol dir="auto">
<li>how about change the data type of field ‘generic’ from ‘String’ to ‘Boolean’ in class AbstractReferenceConfig?</li>
</ol>
<p dir="auto">Pls. provide [GitHub address] to reproduce this issue.</p>
<h3 dir="auto">Expected Result</h3>
<p dir="auto">What do you expected from the above steps？</p>
<h3 dir="auto">Actual Result</h3>
<p dir="auto">What actually happens?</p>
<p dir="auto">If there is an exception, please attach the exception trace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Just put your stack trace here!"><pre class="notranslate"><code class="notranslate">Just put your stack trace here!
</code></pre></div>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have searched the <a href="https://github.com/apache/incubator-dubbo/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have checked the <a href="https://github.com/apache/incubator-dubbo/blob/master/FAQ.md">FAQ</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>Dubbo version: 2.5.x</li>
<li>Operating System version: xxx</li>
<li>Java version: 1.8</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<ol dir="auto">
<li>人为制造异常</li>
</ol>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="        public User getUser ( int id){
            System.out.println(&quot;getUser&quot;);
            System.out.println(String.format(&quot;%s&quot;, 10 / 0));
            User user = new User();
            user.setId(1);
            user.setUsername(&quot;test&quot;);
            user.setPassword(&quot;test&quot;);
            System.out.println(&quot;11111111562&quot;);
            return user;
        }"><pre class="notranslate">        <span class="pl-k">public</span> <span class="pl-smi">User</span> <span class="pl-s1">getUser</span> ( <span class="pl-smi">int</span> <span class="pl-s1">id</span>){
            <span class="pl-smi">System</span>.<span class="pl-s1">out</span>.<span class="pl-en">println</span>(<span class="pl-s">"getUser"</span>);
            <span class="pl-smi">System</span>.<span class="pl-s1">out</span>.<span class="pl-en">println</span>(<span class="pl-smi">String</span>.<span class="pl-en">format</span>(<span class="pl-s">"%s"</span>, <span class="pl-c1">10</span> / <span class="pl-c1">0</span>));
            <span class="pl-smi">User</span> <span class="pl-s1">user</span> = <span class="pl-k">new</span> <span class="pl-smi">User</span>();
            <span class="pl-s1">user</span>.<span class="pl-en">setId</span>(<span class="pl-c1">1</span>);
            <span class="pl-s1">user</span>.<span class="pl-en">setUsername</span>(<span class="pl-s">"test"</span>);
            <span class="pl-s1">user</span>.<span class="pl-en">setPassword</span>(<span class="pl-s">"test"</span>);
            <span class="pl-smi">System</span>.<span class="pl-s1">out</span>.<span class="pl-en">println</span>(<span class="pl-s">"11111111562"</span>);
            <span class="pl-k">return</span> <span class="pl-s1">user</span>;
        }</pre></div>
<ol start="2" dir="auto">
<li>单元测试</li>
</ol>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="        @Test
        public void testEchoException() {
            //echoService.echoWithException();
            echoService.getUser(1);
            System.out.println(&quot;666666666666&quot;);
        }"><pre class="notranslate">        <span class="pl-c1">@</span><span class="pl-c1">Test</span>
        <span class="pl-k">public</span> <span class="pl-smi">void</span> <span class="pl-s1">testEchoException</span>() {
            <span class="pl-c">//echoService.echoWithException();</span>
            <span class="pl-s1">echoService</span>.<span class="pl-en">getUser</span>(<span class="pl-c1">1</span>);
            <span class="pl-smi">System</span>.<span class="pl-s1">out</span>.<span class="pl-en">println</span>(<span class="pl-s">"666666666666"</span>);
        }</pre></div>
<ol start="3" dir="auto">
<li>异常结果</li>
</ol>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="java.lang.ClassCastException: java.lang.String cannot be cast to com.test.dubbo.service.User
	at com.alibaba.dubbo.common.bytecode.proxy0.getUser(proxy0.java)
	at com.test.dubbo.ConsumerTest.testEchoException(ConsumerTest.java:46)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)"><pre class="notranslate"><span class="pl-smi">java</span>.<span class="pl-smi">lang</span>.<span class="pl-smi">ClassCastException</span>: <span class="pl-s1">java</span>.<span class="pl-s1">lang</span>.<span class="pl-s1">String</span> <span class="pl-s1">cannot</span> <span class="pl-s1">be</span> <span class="pl-smi">cast</span> <span class="pl-s1">to</span> <span class="pl-smi">com</span>.<span class="pl-smi">test</span>.<span class="pl-smi">dubbo</span>.<span class="pl-smi">service</span>.<span class="pl-smi">User</span>
	<span class="pl-s1">at</span> <span class="pl-s1">com</span>.<span class="pl-s1">alibaba</span>.<span class="pl-s1">dubbo</span>.<span class="pl-s1">common</span>.<span class="pl-s1">bytecode</span>.<span class="pl-s1">proxy0</span>.<span class="pl-en">getUser</span>(<span class="pl-s1">proxy0</span>.<span class="pl-s1">java</span>)
	<span class="pl-smi">at</span> <span class="pl-s1">com</span>.<span class="pl-s1">test</span>.<span class="pl-s1">dubbo</span>.<span class="pl-s1">ConsumerTest</span>.<span class="pl-s1">testEchoException</span>(<span class="pl-smi">ConsumerTest</span>.<span class="pl-smi">java</span>:<span class="pl-c1">46</span>)
	<span class="pl-smi">at</span> <span class="pl-s1">sun</span>.<span class="pl-s1">reflect</span>.<span class="pl-s1">NativeMethodAccessorImpl</span>.<span class="pl-en">invoke0</span>(<span class="pl-smi">Native</span> <span class="pl-s1">Method</span>)
	<span class="pl-s1">at</span> <span class="pl-s1">sun</span>.<span class="pl-s1">reflect</span>.<span class="pl-s1">NativeMethodAccessorImpl</span>.<span class="pl-en">invoke</span>(<span class="pl-smi">NativeMethodAccessorImpl</span>.<span class="pl-smi">java</span>:<span class="pl-c1">62</span>)
	<span class="pl-s1">at</span> <span class="pl-s1">sun</span>.<span class="pl-s1">reflect</span>.<span class="pl-s1">DelegatingMethodAccessorImpl</span>.<span class="pl-en">invoke</span>(<span class="pl-smi">DelegatingMethodAccessorImpl</span>.<span class="pl-smi">java</span>:<span class="pl-c1">43</span>)
	<span class="pl-s1">at</span> <span class="pl-s1">java</span>.<span class="pl-s1">lang</span>.<span class="pl-s1">reflect</span>.<span class="pl-s1">Method</span>.<span class="pl-en">invoke</span>(<span class="pl-smi">Method</span>.<span class="pl-smi">java</span>:<span class="pl-c1">498</span>)
	<span class="pl-s1">at</span> <span class="pl-s1">org</span>.<span class="pl-s1">junit</span>.<span class="pl-s1">runners</span>.<span class="pl-s1">model</span>.<span class="pl-s1">FrameworkMethod$1</span>.<span class="pl-en">runReflectiveCall</span>(<span class="pl-smi">FrameworkMethod</span>.<span class="pl-smi">java</span>:<span class="pl-c1">50</span>)
	<span class="pl-s1">at</span> <span class="pl-s1">org</span>.<span class="pl-s1">junit</span>.<span class="pl-s1">internal</span>.<span class="pl-s1">runners</span>.<span class="pl-s1">model</span>.<span class="pl-s1">ReflectiveCallable</span>.<span class="pl-en">run</span>(<span class="pl-smi">ReflectiveCallable</span>.<span class="pl-smi">java</span>:<span class="pl-c1">12</span>)
	<span class="pl-s1">at</span> <span class="pl-s1">org</span>.<span class="pl-s1">junit</span>.<span class="pl-s1">runners</span>.<span class="pl-s1">model</span>.<span class="pl-s1">FrameworkMethod</span>.<span class="pl-en">invokeExplosively</span>(<span class="pl-smi">FrameworkMethod</span>.<span class="pl-smi">java</span>:<span class="pl-c1">47</span>)
	<span class="pl-s1">at</span> <span class="pl-s1">org</span>.<span class="pl-s1">junit</span>.<span class="pl-s1">internal</span>.<span class="pl-s1">runners</span>.<span class="pl-s1">statements</span>.<span class="pl-s1">InvokeMethod</span>.<span class="pl-en">evaluate</span>(<span class="pl-smi">InvokeMethod</span>.<span class="pl-smi">java</span>:<span class="pl-c1">17</span>)
	<span class="pl-s1">at</span> <span class="pl-s1">org</span>.<span class="pl-s1">junit</span>.<span class="pl-s1">internal</span>.<span class="pl-s1">runners</span>.<span class="pl-s1">statements</span>.<span class="pl-s1">RunBefores</span>.<span class="pl-en">evaluate</span>(<span class="pl-smi">RunBefores</span>.<span class="pl-smi">java</span>:<span class="pl-c1">26</span>)
	<span class="pl-s1">at</span> <span class="pl-s1">org</span>.<span class="pl-s1">junit</span>.<span class="pl-s1">runners</span>.<span class="pl-s1">ParentRunner</span>.<span class="pl-en">runLeaf</span>(<span class="pl-smi">ParentRunner</span>.<span class="pl-smi">java</span>:<span class="pl-c1">325</span>)
	<span class="pl-s1">at</span> <span class="pl-s1">org</span>.<span class="pl-s1">junit</span>.<span class="pl-s1">runners</span>.<span class="pl-s1">BlockJUnit4ClassRunner</span>.<span class="pl-en">runChild</span>(<span class="pl-smi">BlockJUnit4ClassRunner</span>.<span class="pl-smi">java</span>:<span class="pl-c1">78</span>)
	<span class="pl-s1">at</span> <span class="pl-s1">org</span>.<span class="pl-s1">junit</span>.<span class="pl-s1">runners</span>.<span class="pl-s1">BlockJUnit4ClassRunner</span>.<span class="pl-en">runChild</span>(<span class="pl-smi">BlockJUnit4ClassRunner</span>.<span class="pl-smi">java</span>:<span class="pl-c1">57</span>)
	<span class="pl-s1">at</span> <span class="pl-s1">org</span>.<span class="pl-s1">junit</span>.<span class="pl-s1">runners</span>.<span class="pl-s1">ParentRunner$3</span>.<span class="pl-en">run</span>(<span class="pl-smi">ParentRunner</span>.<span class="pl-smi">java</span>:<span class="pl-c1">290</span>)
	<span class="pl-s1">at</span> <span class="pl-s1">org</span>.<span class="pl-s1">junit</span>.<span class="pl-s1">runners</span>.<span class="pl-s1">ParentRunner$1</span>.<span class="pl-en">schedule</span>(<span class="pl-smi">ParentRunner</span>.<span class="pl-smi">java</span>:<span class="pl-c1">71</span>)
	<span class="pl-s1">at</span> <span class="pl-s1">org</span>.<span class="pl-s1">junit</span>.<span class="pl-s1">runners</span>.<span class="pl-s1">ParentRunner</span>.<span class="pl-en">runChildren</span>(<span class="pl-smi">ParentRunner</span>.<span class="pl-smi">java</span>:<span class="pl-c1">288</span>)
	<span class="pl-s1">at</span> <span class="pl-s1">org</span>.<span class="pl-s1">junit</span>.<span class="pl-s1">runners</span>.<span class="pl-s1">ParentRunner</span>.<span class="pl-en">access$000</span>(<span class="pl-smi">ParentRunner</span>.<span class="pl-smi">java</span>:<span class="pl-c1">58</span>)
	<span class="pl-s1">at</span> <span class="pl-s1">org</span>.<span class="pl-s1">junit</span>.<span class="pl-s1">runners</span>.<span class="pl-s1">ParentRunner$2</span>.<span class="pl-en">evaluate</span>(<span class="pl-smi">ParentRunner</span>.<span class="pl-smi">java</span>:<span class="pl-c1">268</span>)
	<span class="pl-s1">at</span> <span class="pl-s1">org</span>.<span class="pl-s1">junit</span>.<span class="pl-s1">runners</span>.<span class="pl-s1">ParentRunner</span>.<span class="pl-en">run</span>(<span class="pl-smi">ParentRunner</span>.<span class="pl-smi">java</span>:<span class="pl-c1">363</span>)
	<span class="pl-s1">at</span> <span class="pl-s1">org</span>.<span class="pl-s1">eclipse</span>.<span class="pl-s1">jdt</span>.<span class="pl-s1">internal</span>.<span class="pl-s1">junit4</span>.<span class="pl-s1">runner</span>.<span class="pl-s1">JUnit4TestReference</span>.<span class="pl-en">run</span>(<span class="pl-smi">JUnit4TestReference</span>.<span class="pl-smi">java</span>:<span class="pl-c1">86</span>)
	<span class="pl-s1">at</span> <span class="pl-s1">org</span>.<span class="pl-s1">eclipse</span>.<span class="pl-s1">jdt</span>.<span class="pl-s1">internal</span>.<span class="pl-s1">junit</span>.<span class="pl-s1">runner</span>.<span class="pl-s1">TestExecution</span>.<span class="pl-en">run</span>(<span class="pl-smi">TestExecution</span>.<span class="pl-smi">java</span>:<span class="pl-c1">38</span>)
	<span class="pl-s1">at</span> <span class="pl-s1">org</span>.<span class="pl-s1">eclipse</span>.<span class="pl-s1">jdt</span>.<span class="pl-s1">internal</span>.<span class="pl-s1">junit</span>.<span class="pl-s1">runner</span>.<span class="pl-s1">RemoteTestRunner</span>.<span class="pl-en">runTests</span>(<span class="pl-smi">RemoteTestRunner</span>.<span class="pl-smi">java</span>:<span class="pl-c1">459</span>)
	<span class="pl-s1">at</span> <span class="pl-s1">org</span>.<span class="pl-s1">eclipse</span>.<span class="pl-s1">jdt</span>.<span class="pl-s1">internal</span>.<span class="pl-s1">junit</span>.<span class="pl-s1">runner</span>.<span class="pl-s1">RemoteTestRunner</span>.<span class="pl-en">runTests</span>(<span class="pl-smi">RemoteTestRunner</span>.<span class="pl-smi">java</span>:<span class="pl-c1">675</span>)
	<span class="pl-s1">at</span> <span class="pl-s1">org</span>.<span class="pl-s1">eclipse</span>.<span class="pl-s1">jdt</span>.<span class="pl-s1">internal</span>.<span class="pl-s1">junit</span>.<span class="pl-s1">runner</span>.<span class="pl-s1">RemoteTestRunner</span>.<span class="pl-en">run</span>(<span class="pl-smi">RemoteTestRunner</span>.<span class="pl-smi">java</span>:<span class="pl-c1">382</span>)
	<span class="pl-s1">at</span> <span class="pl-s1">org</span>.<span class="pl-s1">eclipse</span>.<span class="pl-s1">jdt</span>.<span class="pl-s1">internal</span>.<span class="pl-s1">junit</span>.<span class="pl-s1">runner</span>.<span class="pl-s1">RemoteTestRunner</span>.<span class="pl-en">main</span>(<span class="pl-smi">RemoteTestRunner</span>.<span class="pl-smi">java</span>:<span class="pl-c1">192</span>)</pre></div>
<ol start="4" dir="auto">
<li>HystrixFilter过滤器：</li>
</ol>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="package com.netease.hystrix.dubbo.rpc.filter;
import com.alibaba.dubbo.common.Constants;
import com.alibaba.dubbo.common.extension.Activate;
import com.alibaba.dubbo.rpc.Filter;
import com.alibaba.dubbo.rpc.Invocation;
import com.alibaba.dubbo.rpc.Invoker;
import com.alibaba.dubbo.rpc.Result;
import com.alibaba.dubbo.rpc.RpcException;

@Activate(group = Constants.CONSUMER)
public class HystrixFilter implements Filter {

    @Override
    public Result invoke(Invoker&lt;?&gt; invoker, Invocation invocation) throws RpcException {
        DubboHystrixCommand command = new DubboHystrixCommand(invoker, invocation);
        return command.execute();
    }
}"><pre class="notranslate"><span class="pl-k">package</span> <span class="pl-s1">com</span>.<span class="pl-s1">netease</span>.<span class="pl-s1">hystrix</span>.<span class="pl-s1">dubbo</span>.<span class="pl-s1">rpc</span>.<span class="pl-s1">filter</span>;
<span class="pl-k">import</span> <span class="pl-s1">com</span>.<span class="pl-s1">alibaba</span>.<span class="pl-s1">dubbo</span>.<span class="pl-s1">common</span>.<span class="pl-s1">Constants</span>;
<span class="pl-k">import</span> <span class="pl-s1">com</span>.<span class="pl-s1">alibaba</span>.<span class="pl-s1">dubbo</span>.<span class="pl-s1">common</span>.<span class="pl-s1">extension</span>.<span class="pl-s1">Activate</span>;
<span class="pl-k">import</span> <span class="pl-s1">com</span>.<span class="pl-s1">alibaba</span>.<span class="pl-s1">dubbo</span>.<span class="pl-s1">rpc</span>.<span class="pl-s1">Filter</span>;
<span class="pl-k">import</span> <span class="pl-s1">com</span>.<span class="pl-s1">alibaba</span>.<span class="pl-s1">dubbo</span>.<span class="pl-s1">rpc</span>.<span class="pl-s1">Invocation</span>;
<span class="pl-k">import</span> <span class="pl-s1">com</span>.<span class="pl-s1">alibaba</span>.<span class="pl-s1">dubbo</span>.<span class="pl-s1">rpc</span>.<span class="pl-s1">Invoker</span>;
<span class="pl-k">import</span> <span class="pl-s1">com</span>.<span class="pl-s1">alibaba</span>.<span class="pl-s1">dubbo</span>.<span class="pl-s1">rpc</span>.<span class="pl-s1">Result</span>;
<span class="pl-k">import</span> <span class="pl-s1">com</span>.<span class="pl-s1">alibaba</span>.<span class="pl-s1">dubbo</span>.<span class="pl-s1">rpc</span>.<span class="pl-s1">RpcException</span>;

<span class="pl-c1">@</span><span class="pl-c1">Activate</span>(<span class="pl-s1">group</span> = <span class="pl-smi">Constants</span>.<span class="pl-c1">CONSUMER</span>)
<span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-smi">HystrixFilter</span> <span class="pl-k">implements</span> <span class="pl-smi">Filter</span> {

    <span class="pl-c1">@</span><span class="pl-c1">Override</span>
    <span class="pl-k">public</span> <span class="pl-smi">Result</span> <span class="pl-en">invoke</span>(<span class="pl-smi">Invoker</span>&lt;?&gt; <span class="pl-s1">invoker</span>, <span class="pl-smi">Invocation</span> <span class="pl-s1">invocation</span>) <span class="pl-k">throws</span> <span class="pl-smi">RpcException</span> {
        <span class="pl-smi">DubboHystrixCommand</span> <span class="pl-s1">command</span> = <span class="pl-k">new</span> <span class="pl-smi">DubboHystrixCommand</span>(<span class="pl-s1">invoker</span>, <span class="pl-s1">invocation</span>);
        <span class="pl-k">return</span> <span class="pl-s1">command</span>.<span class="pl-en">execute</span>();
    }
}</pre></div>
<ol start="5" dir="auto">
<li>DubboHystrixCommand 类：</li>
</ol>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="package com.netease.hystrix.dubbo.rpc.filter;

import org.apache.log4j.Logger;

import com.alibaba.dubbo.common.URL;
import com.alibaba.dubbo.rpc.Invocation;
import com.alibaba.dubbo.rpc.Invoker;
import com.alibaba.dubbo.rpc.Result;
import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixCommandKey;
import com.netflix.hystrix.HystrixCommandProperties;
import com.netflix.hystrix.HystrixThreadPoolProperties;

public class DubboHystrixCommand extends HystrixCommand&lt;Result&gt; {

    private static Logger    logger                       = Logger.getLogger(DubboHystrixCommand.class);
    private static final int DEFAULT_THREADPOOL_CORE_SIZE = 30;
    private Invoker&lt;?&gt;       invoker;
    private Invocation       invocation;
    
    public DubboHystrixCommand(Invoker&lt;?&gt; invoker,Invocation invocation){
        super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(invoker.getInterface().getName()))
                    .andCommandKey(HystrixCommandKey.Factory.asKey(String.format(&quot;%s_%d&quot;, invocation.getMethodName(),
                                                                                 invocation.getArguments() == null ? 0 : invocation.getArguments().length)))
              .andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
                                            .withCircuitBreakerRequestVolumeThreshold(20)//10秒钟内至少19此请求失败，熔断器才发挥起作用
                                            .withCircuitBreakerSleepWindowInMilliseconds(30000)//熔断器中断请求30秒后会进入半打开状态,放部分流量过去重试
                                            .withCircuitBreakerErrorThresholdPercentage(50)//错误率达到50开启熔断保护
                                            .withExecutionTimeoutEnabled(false))//使用dubbo的超时，禁用这里的超时
              .andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter().withCoreSize(getThreadPoolCoreSize(invoker.getUrl()))));//线程池为30
       
        
        this.invoker=invoker;
        this.invocation=invocation;
    }
    
    /**
     * 获取线程池大小
     * 
     * @param url
     * @return
     */
    private static int getThreadPoolCoreSize(URL url) {
        if (url != null) {
            int size = url.getParameter(&quot;ThreadPoolCoreSize&quot;, DEFAULT_THREADPOOL_CORE_SIZE);
            if (logger.isDebugEnabled()) {
                logger.debug(&quot;ThreadPoolCoreSize:&quot; + size);
            }
            return size;
        }

        return DEFAULT_THREADPOOL_CORE_SIZE;

    }

    @Override
    protected Result run() throws Exception {
        return invoker.invoke(invocation);
    }
}"><pre class="notranslate"><span class="pl-k">package</span> <span class="pl-s1">com</span>.<span class="pl-s1">netease</span>.<span class="pl-s1">hystrix</span>.<span class="pl-s1">dubbo</span>.<span class="pl-s1">rpc</span>.<span class="pl-s1">filter</span>;

<span class="pl-k">import</span> <span class="pl-s1">org</span>.<span class="pl-s1">apache</span>.<span class="pl-s1">log4j</span>.<span class="pl-s1">Logger</span>;

<span class="pl-k">import</span> <span class="pl-s1">com</span>.<span class="pl-s1">alibaba</span>.<span class="pl-s1">dubbo</span>.<span class="pl-s1">common</span>.<span class="pl-c1">URL</span>;
<span class="pl-k">import</span> <span class="pl-s1">com</span>.<span class="pl-s1">alibaba</span>.<span class="pl-s1">dubbo</span>.<span class="pl-s1">rpc</span>.<span class="pl-s1">Invocation</span>;
<span class="pl-k">import</span> <span class="pl-s1">com</span>.<span class="pl-s1">alibaba</span>.<span class="pl-s1">dubbo</span>.<span class="pl-s1">rpc</span>.<span class="pl-s1">Invoker</span>;
<span class="pl-k">import</span> <span class="pl-s1">com</span>.<span class="pl-s1">alibaba</span>.<span class="pl-s1">dubbo</span>.<span class="pl-s1">rpc</span>.<span class="pl-s1">Result</span>;
<span class="pl-k">import</span> <span class="pl-s1">com</span>.<span class="pl-s1">netflix</span>.<span class="pl-s1">hystrix</span>.<span class="pl-s1">HystrixCommand</span>;
<span class="pl-k">import</span> <span class="pl-s1">com</span>.<span class="pl-s1">netflix</span>.<span class="pl-s1">hystrix</span>.<span class="pl-s1">HystrixCommandGroupKey</span>;
<span class="pl-k">import</span> <span class="pl-s1">com</span>.<span class="pl-s1">netflix</span>.<span class="pl-s1">hystrix</span>.<span class="pl-s1">HystrixCommandKey</span>;
<span class="pl-k">import</span> <span class="pl-s1">com</span>.<span class="pl-s1">netflix</span>.<span class="pl-s1">hystrix</span>.<span class="pl-s1">HystrixCommandProperties</span>;
<span class="pl-k">import</span> <span class="pl-s1">com</span>.<span class="pl-s1">netflix</span>.<span class="pl-s1">hystrix</span>.<span class="pl-s1">HystrixThreadPoolProperties</span>;

<span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-smi">DubboHystrixCommand</span> <span class="pl-k">extends</span> <span class="pl-smi">HystrixCommand</span>&lt;<span class="pl-smi">Result</span>&gt; {

    <span class="pl-k">private</span> <span class="pl-k">static</span> <span class="pl-smi">Logger</span>    <span class="pl-s1">logger</span>                       = <span class="pl-smi">Logger</span>.<span class="pl-en">getLogger</span>(<span class="pl-smi">DubboHystrixCommand</span>.<span class="pl-k">class</span>);
    <span class="pl-k">private</span> <span class="pl-k">static</span> <span class="pl-k">final</span> <span class="pl-smi">int</span> <span class="pl-c1">DEFAULT_THREADPOOL_CORE_SIZE</span> = <span class="pl-c1">30</span>;
    <span class="pl-k">private</span> <span class="pl-smi">Invoker</span>&lt;?&gt;       <span class="pl-s1">invoker</span>;
    <span class="pl-k">private</span> <span class="pl-smi">Invocation</span>       <span class="pl-s1">invocation</span>;
    
    <span class="pl-k">public</span> <span class="pl-smi">DubboHystrixCommand</span>(<span class="pl-smi">Invoker</span>&lt;?&gt; <span class="pl-s1">invoker</span>,<span class="pl-smi">Invocation</span> <span class="pl-s1">invocation</span>){
        <span class="pl-en">super</span>(<span class="pl-smi">Setter</span>.<span class="pl-en">withGroupKey</span>(<span class="pl-smi">HystrixCommandGroupKey</span>.<span class="pl-s1">Factory</span>.<span class="pl-en">asKey</span>(<span class="pl-s1">invoker</span>.<span class="pl-en">getInterface</span>().<span class="pl-en">getName</span>()))
                    .<span class="pl-en">andCommandKey</span>(<span class="pl-smi">HystrixCommandKey</span>.<span class="pl-s1">Factory</span>.<span class="pl-en">asKey</span>(<span class="pl-smi">String</span>.<span class="pl-en">format</span>(<span class="pl-s">"%s_%d"</span>, <span class="pl-s1">invocation</span>.<span class="pl-en">getMethodName</span>(),
                                                                                 <span class="pl-s1">invocation</span>.<span class="pl-en">getArguments</span>() == <span class="pl-c1">null</span> ? <span class="pl-c1">0</span> : <span class="pl-s1">invocation</span>.<span class="pl-en">getArguments</span>().<span class="pl-s1">length</span>)))
              .<span class="pl-en">andCommandPropertiesDefaults</span>(<span class="pl-smi">HystrixCommandProperties</span>.<span class="pl-en">Setter</span>()
                                            .<span class="pl-en">withCircuitBreakerRequestVolumeThreshold</span>(<span class="pl-c1">20</span>)<span class="pl-c">//10秒钟内至少19此请求失败，熔断器才发挥起作用</span>
                                            .<span class="pl-en">withCircuitBreakerSleepWindowInMilliseconds</span>(<span class="pl-c1">30000</span>)<span class="pl-c">//熔断器中断请求30秒后会进入半打开状态,放部分流量过去重试</span>
                                            .<span class="pl-en">withCircuitBreakerErrorThresholdPercentage</span>(<span class="pl-c1">50</span>)<span class="pl-c">//错误率达到50开启熔断保护</span>
                                            .<span class="pl-en">withExecutionTimeoutEnabled</span>(<span class="pl-c1">false</span>))<span class="pl-c">//使用dubbo的超时，禁用这里的超时</span>
              .<span class="pl-en">andThreadPoolPropertiesDefaults</span>(<span class="pl-smi">HystrixThreadPoolProperties</span>.<span class="pl-en">Setter</span>().<span class="pl-en">withCoreSize</span>(<span class="pl-en">getThreadPoolCoreSize</span>(<span class="pl-s1">invoker</span>.<span class="pl-en">getUrl</span>()))));<span class="pl-c">//线程池为30</span>
       
        
        <span class="pl-smi">this</span>.<span class="pl-s1">invoker</span>=<span class="pl-s1">invoker</span>;
        <span class="pl-smi">this</span>.<span class="pl-s1">invocation</span>=<span class="pl-s1">invocation</span>;
    }
    
    <span class="pl-c">/**</span>
<span class="pl-c">     * 获取线程池大小</span>
<span class="pl-c">     * </span>
<span class="pl-c">     * @param url</span>
<span class="pl-c">     * @return</span>
<span class="pl-c">     */</span>
    <span class="pl-k">private</span> <span class="pl-k">static</span> <span class="pl-smi">int</span> <span class="pl-en">getThreadPoolCoreSize</span>(<span class="pl-smi">URL</span> <span class="pl-s1">url</span>) {
        <span class="pl-k">if</span> (<span class="pl-s1">url</span> != <span class="pl-c1">null</span>) {
            <span class="pl-smi">int</span> <span class="pl-s1">size</span> = <span class="pl-s1">url</span>.<span class="pl-en">getParameter</span>(<span class="pl-s">"ThreadPoolCoreSize"</span>, <span class="pl-c1">DEFAULT_THREADPOOL_CORE_SIZE</span>);
            <span class="pl-k">if</span> (<span class="pl-s1">logger</span>.<span class="pl-en">isDebugEnabled</span>()) {
                <span class="pl-s1">logger</span>.<span class="pl-en">debug</span>(<span class="pl-s">"ThreadPoolCoreSize:"</span> + <span class="pl-s1">size</span>);
            }
            <span class="pl-k">return</span> <span class="pl-s1">size</span>;
        }

        <span class="pl-k">return</span> <span class="pl-c1">DEFAULT_THREADPOOL_CORE_SIZE</span>;

    }

    <span class="pl-c1">@</span><span class="pl-c1">Override</span>
    <span class="pl-k">protected</span> <span class="pl-smi">Result</span> <span class="pl-en">run</span>() <span class="pl-k">throws</span> <span class="pl-smi">Exception</span> {
        <span class="pl-k">return</span> <span class="pl-s1">invoker</span>.<span class="pl-en">invoke</span>(<span class="pl-s1">invocation</span>);
    }
}</pre></div>
<ol start="6" dir="auto">
<li>配置：<br>
在resources/META-INF新建dubbo文件夹<br>
hystrixFilter=com.netease.hystrix.dubbo.rpc.filter.HystrixFilter</li>
</ol>
<p dir="auto">人为制造了一个异常，如果方法返回void和String类型的话没问题，如果是返回List、实体类等就报以上错！达不到熔断或降级的错误，会是什么原因？该如何处理。。。</p>