code: void handleFailure(IOException ex, int failures)
        throws IOException {
      // Check if the exception was thrown by the network stack
      if (failoverClient.isShuttingdown() || !shouldHandleException(ex)) {
        throw ex;
      }
      if (failures > FAILURE_RETRY) {
        throw ex;
      }
      try {
        // This might've happened because we are failing over
        if (!watchZK) {
          LOG.debug("Not watching ZK, so checking explicitly");
          // Check with zookeeper
          fsLock.readLock().unlock();
          InjectionHandler.processEvent(InjectionEvent.DAFS_CHECK_FAILOVER);
          fsLock.writeLock().lock();
          boolean failover = false;
          try {
            failover = zkCheckFailover(ex);
          } finally {
            fsLock.writeLock().unlock();
            fsLock.readLock().lock();
          }
          if (failover) {
            return;
          }
        }
        Thread.sleep(1000);
      } catch (InterruptedException iex) {
        LOG.error("Interrupted while waiting for a failover", iex);
        Thread.currentThread().interrupt();
      }
    }
docs: This function should be called within try..finally which releases
  readlock, if this fails.