Skip to content
Open
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 @@ -290,6 +290,15 @@ Invoker<?> getInvoker(Channel channel, Invocation inv) throws RemotingException
boolean isStubServiceInvoke;
int port = channel.getLocalAddress().getPort();
String path = (String) inv.getObjectAttachmentWithoutConvert(PATH_KEY);
if (path == null) {
throw new RemotingException(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is non-serializable parameter really the only scenario that can make path null here? In the normal Dubbo request format, the service path is encoded/decoded before arguments, and DubboInvoker also sets PATH_KEY before sending the request. So a null path seems more generally like missing/malformed invocation metadata, custom codec/invocation behavior, or decode/protocol incompatibility. Could we make this error message less specific than “Please ensure all parameter types implement Serializable” to avoid another misleading diagnosis?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the careful review — you're right, and I appreciate you pointing this out. A null path indicates missing or corrupted invocation metadata in general, and my original message attributing ▎ it solely to non-serializable parameters could indeed cause another misleading diagnosis

I've updated the message to describe the problem generically and only mention deserialization failure as one of several possible causes (along with protocol incompatibility and custom
codec/invocation implementations). Please let me know if the wording could be further improved — happy to adjust.

channel,
"Service path is missing from the invocation, which indicates the invocation metadata is "
+ "missing or corrupted. Possible causes include a request decode failure "
+ "(e.g. parameter types that failed to deserialize), an incompatible protocol "
+ "version, or a custom codec/invocation implementation that does not set the path, "
+ "channel: " + channel.getRemoteAddress() + " --> " + channel.getLocalAddress());
}

// if it's stub service on client side(after enable stubevent, usually is set up onconnect or ondisconnect
// method)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.remoting.Channel;
import org.apache.dubbo.remoting.RemotingException;
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.Protocol;
Expand All @@ -38,6 +40,7 @@
import org.apache.dubbo.rpc.protocol.dubbo.support.Type;
import org.apache.dubbo.rpc.service.EchoService;

import java.net.InetSocketAddress;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -281,6 +284,21 @@ public void testReturnNonSerialized() {
}
}

@Test
void testGetInvokerThrowsOnNullPath() {
DubboProtocol dubboProtocol = DubboProtocol.getDubboProtocol();
Channel channel = Mockito.mock(Channel.class);
InetSocketAddress localAddress = new InetSocketAddress("127.0.0.1", 20880);
InetSocketAddress remoteAddress = new InetSocketAddress("127.0.0.1", 12345);
Mockito.when(channel.getLocalAddress()).thenReturn(localAddress);
Mockito.when(channel.getRemoteAddress()).thenReturn(remoteAddress);

Invocation inv = Mockito.mock(Invocation.class);
Mockito.when(inv.getObjectAttachmentWithoutConvert("path")).thenReturn(null);

Assertions.assertThrows(RemotingException.class, () -> dubboProtocol.getInvoker(channel, inv));
}

@Disabled
@Test
void testRemoteApplicationName() throws Exception {
Expand Down
Loading