code: private boolean methodBasedRecoverLease(String src, boolean discardLastBlock)
      throws IOException {
      // check if closeRecoverLease(discardLastBlock) is supported
      if (namenodeProtocolProxy.isMethodSupported(
          "closeRecoverLease", String.class, String.class, boolean.class)) {
        try {
          return namenode.closeRecoverLease(src, clientName, discardLastBlock);
        } catch (RemoteException re) {
          throw re.unwrapRemoteException(FileNotFoundException.class,
                                         AccessControlException.class);
        }
      }
      // check if closeRecoverLease is supported
      else if (namenodeProtocolProxy.isMethodSupported(
          "closeRecoverLease", String.class, String.class)) {
        try {
          return namenode.closeRecoverLease(src, clientName);
        } catch (RemoteException re) {
          throw re.unwrapRemoteException(FileNotFoundException.class,
                                         AccessControlException.class);
        }
      }
      // check if recoverLease is supported
      if (namenodeProtocolProxy.isMethodSupported(
          "recoverLease", String.class, String.class)) {
        try {
          namenode.recoverLease(src, clientName);
        } catch (RemoteException re) {
          throw re.unwrapRemoteException(FileNotFoundException.class,
                                         AccessControlException.class);
        }
        return !namenode.getBlockLocations(src, 0, Long.MAX_VALUE).isUnderConstruction();
      }
      // now use append
      OutputStream out;
      try {
        out = append(src, conf.getInt("io.file.buffer.size", 4096), null);
      } catch (RemoteException re) {
        IOException e = re.unwrapRemoteException(AlreadyBeingCreatedException.class);
        if (e instanceof AlreadyBeingCreatedException) {
          return false;
        }
        throw re;
      }
      out.close();
      return true;
    }
docs: recover lease based on method name