@@ -15,7 +15,7 @@ | |||
<properties> | |||
<java.source.version>1.8</java.source.version> | |||
<java.target.version>1.8</java.target.version> | |||
<apache.dubbo.version>2.7.3</apache.dubbo.version> | |||
<apache.dubbo.version>2.7.5</apache.dubbo.version> | |||
</properties> | |||
<dependencies> | |||
@@ -22,11 +22,7 @@ import com.alibaba.csp.sentinel.adapter.dubbo.config.DubboConfig; | |||
import com.alibaba.csp.sentinel.context.ContextUtil; | |||
import org.apache.dubbo.common.URL; | |||
import org.apache.dubbo.common.constants.CommonConstants; | |||
import org.apache.dubbo.rpc.Invocation; | |||
import org.apache.dubbo.rpc.Invoker; | |||
import org.apache.dubbo.rpc.ListenableFilter; | |||
import org.apache.dubbo.rpc.Result; | |||
import org.apache.dubbo.rpc.RpcContext; | |||
import org.apache.dubbo.rpc.*; | |||
/** | |||
* Base Class of the {@link SentinelDubboProviderFilter} and {@link SentinelDubboConsumerFilter}. | |||
@@ -41,8 +37,16 @@ public abstract class BaseSentinelDubboFilter extends ListenableFilter { | |||
static class SentinelDubboListener implements Listener { | |||
@Override | |||
public void onResponse(Result appResponse, Invoker<?> invoker, Invocation invocation) { | |||
onSuccess(appResponse, invoker); | |||
} | |||
//for compatible dubbo 2.7.5 rename onResponse to onMessage | |||
public void onMessage(Result appResponse, Invoker<?> invoker, Invocation invocation) { | |||
onSuccess(appResponse, invoker); | |||
} | |||
private void onSuccess(Result appResponse, Invoker<?> invoker) { | |||
if (DubboConfig.getDubboBizExceptionTraceEnabled()) { | |||
traceAndExit(appResponse.getException(), invoker.getUrl()); | |||
} else { | |||
@@ -70,6 +70,6 @@ public class DubboAppContextFilterTest extends BaseTest { | |||
verify(invoker).invoke(invocation); | |||
String application = RpcContext.getContext().getAttachment(DubboUtils.SENTINEL_DUBBO_APPLICATION_KEY); | |||
assertNull(application); | |||
assertEquals(application, ""); | |||
} | |||
} |
@@ -227,7 +227,7 @@ public class SentinelDubboConsumerFilterTest extends BaseTest { | |||
} | |||
public Result responseBack(Result result) { | |||
filter.listener().onResponse(result, invoker, invocation); | |||
filter.listener().onMessage(result, invoker, invocation); | |||
return result; | |||
} | |||
@@ -265,7 +265,7 @@ public class SentinelDubboConsumerFilterTest extends BaseTest { | |||
filter.invoke(invoker, invocation); | |||
verify(invoker).invoke(invocation); | |||
filter.listener().onResponse(result, invoker, invocation); | |||
filter.listener().onMessage(result, invoker, invocation); | |||
Context context = ContextUtil.getContext(); | |||
assertNull(context); | |||
} | |||
@@ -89,7 +89,7 @@ public class SentinelDubboProviderFilterTest extends BaseTest { | |||
filter.invoke(invoker, invocation); | |||
verify(invoker).invoke(invocation); | |||
filter.listener().onResponse(result, invoker, invocation); | |||
filter.listener().onMessage(result, invoker, invocation); | |||
Context context = ContextUtil.getContext(); | |||
assertNull(context); | |||
} | |||