You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2018/04/24 07:31:06 UTC
[incubator-dubbo] branch master updated: Merge pull request #1444,
simplify check consumer side in RpcContext.
This is an automated email from the ASF dual-hosted git repository.
liujun 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 764761d Merge pull request #1444, simplify check consumer side in RpcContext.
764761d is described below
commit 764761dbf6d1131674d9034bfff4af22ae6d0fcb
Author: whanice <34...@users.noreply.github.com>
AuthorDate: Tue Apr 24 15:31:00 2018 +0800
Merge pull request #1444, simplify check consumer side in RpcContext.
---
.../java/com/alibaba/dubbo/rpc/RpcContext.java | 34 ++--------------------
1 file changed, 2 insertions(+), 32 deletions(-)
diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java
index 363b0fa..a542cd6 100644
--- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java
+++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java
@@ -154,22 +154,7 @@ public class RpcContext {
* @return provider side.
*/
public boolean isProviderSide() {
- URL url = getUrl();
- if (url == null) {
- return false;
- }
- InetSocketAddress address = getRemoteAddress();
- if (address == null) {
- return false;
- }
- String host;
- if (address.getAddress() == null) {
- host = address.getHostName();
- } else {
- host = address.getAddress().getHostAddress();
- }
- return url.getPort() != address.getPort() ||
- !NetUtils.filterLocalHost(url.getIp()).equals(NetUtils.filterLocalHost(host));
+ return !isConsumerSide();
}
/**
@@ -178,22 +163,7 @@ public class RpcContext {
* @return consumer side.
*/
public boolean isConsumerSide() {
- URL url = getUrl();
- if (url == null) {
- return false;
- }
- InetSocketAddress address = getRemoteAddress();
- if (address == null) {
- return false;
- }
- String host;
- if (address.getAddress() == null) {
- host = address.getHostName();
- } else {
- host = address.getAddress().getHostAddress();
- }
- return url.getPort() == address.getPort() &&
- NetUtils.filterLocalHost(url.getIp()).equals(NetUtils.filterLocalHost(host));
+ return getUrl().getParameter(Constants.SIDE_KEY, Constants.PROVIDER_SIDE).equals(Constants.CONSUMER_SIDE);
}
/**
--
To stop receiving notification emails like this one, please contact
liujun@apache.org.