Skip to content

Commit

Permalink
HBASE-14431 AsyncRpcClient#removeConnection() never removes connectio…
Browse files Browse the repository at this point in the history
…n from connections pool if server fails (Samir Ahmic)
  • Loading branch information
tedyu committed Sep 19, 2015
1 parent b0f5233 commit 1545e1e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Expand Up @@ -712,6 +712,21 @@ public Void run() throws IOException, InterruptedException {
public int getConnectionHashCode() {
return ConnectionId.hashCode(ticket, serviceName, address);
}

@Override
public int hashCode() {
return getConnectionHashCode();
}

@Override
public boolean equals(Object obj) {
if (obj instanceof AsyncRpcChannel) {
AsyncRpcChannel channel = (AsyncRpcChannel) obj;
return channel.hashCode() == obj.hashCode();
}
return false;
}


@Override
public String toString() {
Expand Down
Expand Up @@ -398,12 +398,12 @@ public void cancelConnections(ServerName sn) {
* Remove connection from pool
*/
public void removeConnection(AsyncRpcChannel connection) {
int connectionHashCode = connection.getConnectionHashCode();
int connectionHashCode = connection.hashCode();
synchronized (connections) {
// we use address as cache key, so we should check here to prevent removing the
// wrong connection
AsyncRpcChannel connectionInPool = this.connections.get(connectionHashCode);
if (connectionInPool == connection) {
if (connectionInPool.equals(connection)) {
this.connections.remove(connectionHashCode);
} else if (LOG.isDebugEnabled()) {
LOG.debug(String.format("%s already removed, expected instance %08x, actual %08x",
Expand Down

0 comments on commit 1545e1e

Please sign in to comment.