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,14 @@ 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(
channel,
"Failed to resolve service path from invocation. "
+ "This may be caused by non-serializable request parameters. "
+ "Please ensure all parameter types implement java.io.Serializable, "
+ "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