apache / apache/dubbo-spi-extensions
NPE encountered when using dubbo-mock-admin
- Dominant language
- Java
- Stars
- 206
- Forks
- 121
- PR merge metrics
- No merged PRs in 30d
Description
### Environment
* Dubbo version: 3.0.8
* Dubbo Admin version: 0.4.0
* dubbo-mock-admin version: 3.0.6-SNAPSHOT
Add depedency `dubbo-mock-admin` in consumer project, using the `AdminMockFilter` provided.
I found that after mockResult got by `mockService.mock(mockContext)`,
if the result is not enable, then`invoker.invoke(invocation)` will throw NPE.
It seems that the `consumerUrl` has been changed in `RpcServiceContext`,
the protocolServiceKey is `org.apache.dubbo.mock.api.MockService`,
and `getServiceInfo(protocolServiceKey)` can't get the serviceInfo.
### Exception trace:
```
[nio-9092-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
java.lang.NullPointerException: null
at org.apache.dubbo.registry.client.InstanceAddressURL.getServiceMethodParameter(InstanceAddressURL.java:243) ~[dubbo-3.0.8.jar:3.0.8]
at org.apache.dubbo.registry.client.InstanceAddressURL.getMethodParameter(InstanceAddressURL.java:266) ~[dubbo-3.0.8.jar:3.0.8]
at org.apache.dubbo.common.URL.getMethodParameter(URL.java:834) ~[dubbo-3.0.8.jar:3.0.8]
at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.initLoadBalance(AbstractClusterInvoker.java:425) ~[dubbo-3.0.8.jar:3.0.8]
at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:335) ~[dubbo-3.0.8.jar:3.0.8]
at org.apache.dubbo.rpc.cluster.router.RouterSnapshotFilter.invoke(RouterSnapshotFilter.java:46) ~[dubbo-3.0.8.jar:3.0.8]
at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:321) ~[dubbo-3.0.8.jar:3.0.8]
at org.apache.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:99) ~[dubbo-3.0.8.jar:3.0.8]
at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:321) ~[dubbo-3.0.8.jar:3.0.8]
at org.apache.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:51) ~[dubbo-3.0.8.jar:3.0.8]
at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:321) ~[dubbo-3.0.8.jar:3.0.8]
at org.apache.dubbo.mock.filter.AdminMockFilter.invoke(AdminMockFilter.java:148) ~[dubbo-mock-admin-3.0.6-SNAPSHOT.jar:3.0.6-SNAPSHOT]
...
```
Contributor guide
Research direction
Start at AdminMockFilter.invoke, especially the call path around AdminMockFilter.java:148, then trace InstanceAddressURL.getServiceMethodParameter at line 243 and the RpcServiceContext consumerUrl/serviceInfo lookup. Reproduce the disabled-mockResult path and verify that invoker.invoke(invocation) no longer throws a NullPointerException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100