Skip to content

Commit 72fe93b

Browse files
beiwei30cvictory
authored andcommitted
fix issue #3713: org.apache.dubbo.rpc.support.MockInvoker#getInterface should not return null (#3716)
1 parent 86b1a98 commit 72fe93b

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public Result invoke(Invocation invocation) throws RpcException {
8888
if (e.isBiz()) {
8989
throw e;
9090
}
91-
91+
9292
if (logger.isWarnEnabled()) {
9393
logger.warn("fail-mock: " + invocation.getMethodName() + " fail-mock enabled , url : " + directory.getUrl(), e);
9494
}
@@ -105,7 +105,7 @@ private Result doMockInvoke(Invocation invocation, RpcException e) {
105105

106106
List<Invoker<T>> mockInvokers = selectMockInvoker(invocation);
107107
if (CollectionUtils.isEmpty(mockInvokers)) {
108-
minvoker = (Invoker<T>) new MockInvoker(directory.getUrl());
108+
minvoker = (Invoker<T>) new MockInvoker(directory.getUrl(), directory.getInterface());
109109
} else {
110110
minvoker = mockInvokers.get(0);
111111
}

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/MockInvoker.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ final public class MockInvoker<T> implements Invoker<T> {
4646
private final static Map<String, Throwable> throwables = new ConcurrentHashMap<String, Throwable>();
4747

4848
private final URL url;
49+
private final Class<T> type;
4950

50-
public MockInvoker(URL url) {
51+
public MockInvoker(URL url, Class<T> type) {
5152
this.url = url;
53+
this.type = type;
5254
}
5355

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

252254
@Override
253255
public Class<T> getInterface() {
254-
//FIXME
255-
return null;
256+
return type;
256257
}
257258
}

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/MockProtocol.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ public <T> Exporter<T> export(Invoker<T> invoker) throws RpcException {
3939

4040
@Override
4141
public <T> Invoker<T> refer(Class<T> type, URL url) throws RpcException {
42-
return new MockInvoker<T>(url);
42+
return new MockInvoker<>(url, type);
4343
}
4444
}

0 commit comments

Comments
 (0)