code: private boolean versionBasedRecoverLease(String src) throws IOException {
  
      if (namenodeVersion < ClientProtocol.RECOVER_LEASE_VERSION) {
        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;
      } else if (namenodeVersion < ClientProtocol.CLOSE_RECOVER_LEASE_VERSION){
        try {
          namenode.recoverLease(src, clientName);
        } catch (RemoteException re) {
          throw re.unwrapRemoteException(FileNotFoundException.class,
                                         AccessControlException.class);
        }
        return !namenode.getBlockLocations(src, 0, Long.MAX_VALUE).isUnderConstruction();
      } else {
        try {
          return namenode.closeRecoverLease(src, clientName, false);
        } catch (RemoteException re) {
          throw re.unwrapRemoteException(FileNotFoundException.class,
                                         AccessControlException.class);
        }
      }
    }
docs: recover lease based on version