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

sentinel-apache-dubbo-adapter not compatible dubbo 2.7.5 #1296

Merged
merged 2 commits into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sentinel-adapter/sentinel-apache-dubbo-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@
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}.
Expand All @@ -41,8 +37,16 @@ public BaseSentinelDubboFilter() {

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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ public void testInvokeNullApplicationKey() {
verify(invoker).invoke(invocation);

String application = RpcContext.getContext().getAttachment(DubboUtils.SENTINEL_DUBBO_APPLICATION_KEY);
assertNull(application);
assertEquals(application, "");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public Result requestGo(boolean exception, Invocation currentInvocation) {
}

public Result responseBack(Result result) {
filter.listener().onResponse(result, invoker, invocation);
filter.listener().onMessage(result, invoker, invocation);
return result;
}

Expand Down Expand Up @@ -265,7 +265,7 @@ public void testInvokeSync() {
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void testInvoke() {
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);
}
Expand Down