This is an automated email from the ASF dual-hosted git repository.
carryxyh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new e3aac2d Fix thrift protocol, use path to locate exporter. (#3331)
e3aac2d is described below
commit e3aac2dd2ab9f09d2a27fdf9f2e6cccb1a34bf7f
Author: ken.lj <[email protected]>
AuthorDate: Fri Jan 25 10:23:08 2019 +0800
Fix thrift protocol, use path to locate exporter. (#3331)
* Fix thrift protocol, use path to locate exporter.
* Fix UT
---
.../java/org/apache/dubbo/rpc/protocol/thrift/ThriftCodec.java | 5 +++++
.../org/apache/dubbo/rpc/protocol/thrift/ThriftProtocol.java | 4 ++--
.../org/apache/dubbo/rpc/protocol/thrift/ThriftCodecTest.java | 10 ++++++++++
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git
a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/ThriftCodec.java
b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/ThriftCodec.java
index d171ce1..58058f4 100644
---
a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/ThriftCodec.java
+++
b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/ThriftCodec.java
@@ -163,6 +163,7 @@ public class ThriftCodec implements Codec2 {
// version
String serviceName;
+ String path;
long id;
TMessage message;
@@ -171,6 +172,7 @@ public class ThriftCodec implements Codec2 {
protocol.readI16();
protocol.readByte();
serviceName = protocol.readString();
+ path = protocol.readString();
id = protocol.readI64();
message = protocol.readMessageBegin();
} catch (TException e) {
@@ -181,6 +183,7 @@ public class ThriftCodec implements Codec2 {
RpcInvocation result = new RpcInvocation();
result.setAttachment(Constants.INTERFACE_KEY, serviceName);
+ result.setAttachment(Constants.PATH_KEY, path);
result.setMethodName(message.name);
String argsClassName =
ExtensionLoader.getExtensionLoader(ClassNameGenerator.class)
@@ -496,6 +499,8 @@ public class ThriftCodec implements Codec2 {
protocol.writeByte(VERSION);
// service name
protocol.writeString(serviceName);
+ // path
+ protocol.writeString(inv.getAttachment(Constants.PATH_KEY));
// dubbo request id
protocol.writeI64(request.getId());
protocol.getTransport().flush();
diff --git
a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/ThriftProtocol.java
b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/ThriftProtocol.java
index 958d8e6..055af6f 100644
---
a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/ThriftProtocol.java
+++
b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/ThriftProtocol.java
@@ -63,9 +63,9 @@ public class ThriftProtocol extends AbstractProtocol {
if (msg instanceof Invocation) {
Invocation inv = (Invocation) msg;
- String serviceName =
inv.getAttachments().get(Constants.INTERFACE_KEY);
+ String path = inv.getAttachments().get(Constants.PATH_KEY);
String serviceKey =
serviceKey(channel.getLocalAddress().getPort(),
- serviceName, null, null);
+ path, null, null);
DubboExporter<?> exporter = (DubboExporter<?>)
exporterMap.get(serviceKey);
if (exporter == null) {
throw new RemotingException(channel,
diff --git
a/dubbo-rpc/dubbo-rpc-thrift/src/test/java/org/apache/dubbo/rpc/protocol/thrift/ThriftCodecTest.java
b/dubbo-rpc/dubbo-rpc-thrift/src/test/java/org/apache/dubbo/rpc/protocol/thrift/ThriftCodecTest.java
index c738a46..c2277f7 100644
---
a/dubbo-rpc/dubbo-rpc-thrift/src/test/java/org/apache/dubbo/rpc/protocol/thrift/ThriftCodecTest.java
+++
b/dubbo-rpc/dubbo-rpc-thrift/src/test/java/org/apache/dubbo/rpc/protocol/thrift/ThriftCodecTest.java
@@ -93,6 +93,8 @@ public class ThriftCodecTest {
Assertions.assertEquals(ThriftCodec.VERSION, protocol.readByte());
// service name
Assertions.assertEquals(Demo.Iface.class.getName(),
protocol.readString());
+ // path
+ Assertions.assertEquals(Demo.Iface.class.getName(),
protocol.readString());
// dubbo request id
Assertions.assertEquals(request.getId(), protocol.readI64());
@@ -148,6 +150,8 @@ public class ThriftCodecTest {
protocol.writeI16(Short.MAX_VALUE);
protocol.writeByte(ThriftCodec.VERSION);
protocol.writeString(Demo.Iface.class.getName());
+ // path
+ protocol.writeString(Demo.Iface.class.getName());
protocol.writeI64(request.getId());
protocol.getTransport().flush();
headerLength = bos.size();
@@ -221,6 +225,8 @@ public class ThriftCodecTest {
protocol.writeI16(Short.MAX_VALUE);
protocol.writeByte(ThriftCodec.VERSION);
protocol.writeString(Demo.class.getName());
+ // path
+ protocol.writeString(Demo.class.getName());
protocol.writeI64(request.getId());
protocol.getTransport().flush();
headerLength = bos.size();
@@ -396,6 +402,9 @@ public class ThriftCodecTest {
protocol.writeString(
((RpcInvocation) request.getData())
.getAttachment(Constants.INTERFACE_KEY));
+ protocol.writeString(
+ ((RpcInvocation) request.getData())
+ .getAttachment(Constants.PATH_KEY));
protocol.writeI64(request.getId());
protocol.getTransport().flush();
headerLength = bos.size();
@@ -448,6 +457,7 @@ public class ThriftCodecTest {
invocation.setParameterTypes(new Class<?>[]{String.class});
invocation.setAttachment(Constants.INTERFACE_KEY,
Demo.Iface.class.getName());
+ invocation.setAttachment(Constants.PATH_KEY,
Demo.Iface.class.getName());
Request request = new Request(1L);