Skip to content

Commit

Permalink
Merge pull request #1444, simplify check consumer side in RpcContext.
Browse files Browse the repository at this point in the history
  • Loading branch information
imsunv authored and chickenlj committed Apr 24, 2018
1 parent e345ba2 commit 764761d
Showing 1 changed file with 2 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,22 +154,7 @@ public void setResponse(Object response) {
* @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();
}

/**
Expand All @@ -178,22 +163,7 @@ public boolean isProviderSide() {
* @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);
}

/**
Expand Down

0 comments on commit 764761d

Please sign in to comment.