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

[DUBBO-3713]: org.apache.dubbo.rpc.support.MockInvoker#getInterface should not return null #3716

Merged
merged 1 commit into from
Apr 29, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public Result invoke(Invocation invocation) throws RpcException {
if (e.isBiz()) {
throw e;
}

if (logger.isWarnEnabled()) {
logger.warn("fail-mock: " + invocation.getMethodName() + " fail-mock enabled , url : " + directory.getUrl(), e);
}
Expand All @@ -105,7 +105,7 @@ private Result doMockInvoke(Invocation invocation, RpcException e) {

List<Invoker<T>> mockInvokers = selectMockInvoker(invocation);
if (CollectionUtils.isEmpty(mockInvokers)) {
minvoker = (Invoker<T>) new MockInvoker(directory.getUrl());
minvoker = (Invoker<T>) new MockInvoker(directory.getUrl(), directory.getInterface());
} else {
minvoker = mockInvokers.get(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ final public class MockInvoker<T> implements Invoker<T> {
private final static Map<String, Throwable> throwables = new ConcurrentHashMap<String, Throwable>();

private final URL url;
private final Class<T> type;

public MockInvoker(URL url) {
public MockInvoker(URL url, Class<T> type) {
beiwei30 marked this conversation as resolved.
Show resolved Hide resolved
this.url = url;
this.type = type;
}

public static Object parseMockValue(String mock) throws Exception {
Expand Down Expand Up @@ -251,7 +253,6 @@ public void destroy() {

@Override
public Class<T> getInterface() {
//FIXME
return null;
return type;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ public <T> Exporter<T> export(Invoker<T> invoker) throws RpcException {

@Override
public <T> Invoker<T> refer(Class<T> type, URL url) throws RpcException {
return new MockInvoker<T>(url);
return new MockInvoker<>(url, type);
}
}