Description
When HBaseClient.stop() is invoked, all cached HBaseClient.Connections will be interrupted, marked as closed and then finally closed. HBaseClient.stop() won't return before all cached HBaseClient.Connections have been closed. However, SecureConnection might not be closed after HBaseClient.stop() is invoked because of the following code in SecureClient,setupIOstreams():
... try { ... try { continueSasl = ticket.runAs(new PrivilegedExceptionAction<Boolean>() { @Override public Boolean run() throws IOException { return setupSaslConnection(in2, out2); } }); } catch (Exception ex) { if (rand == null) { rand = new Random(); } // == InterruptedException won't be caught == handleSaslConnectionFailure(numRetries++, MAX_RETRIES, ex, rand, ticket); continue; ... } } } catch (IOException e) { markClosed(e); close(); throw e; } ...
SecureClient.handleSaslConnectionFailure(...) will throw InterruptedException exception(there will be Thread.sleep() in SecureClient.handleSaslConnectionFailure(...)) when HBaseClient#stop() is invoked. However, this InterruptedException won't be caught, making this SecureConnection can't be closed.
This problem might make regionserver can't exit because regionserver will wait all SecureConnection closed when exiting. A simple way to fix this bug is to catch InterruptedException in SecureClient#setupIOstreams() and close the SecureConnection.