public RegionLocations remove(HRegionLocation location) {
    if (location == null) return this;
    if (location.getRegion() == null) return this;
    int replicaId = location.getRegion().getReplicaId();
    if (replicaId >= locations.length) return this;

    // check whether something to remove. HRL.compareTo() compares ONLY the
    // serverName. We want to compare the HRI's as well.
    if (
      locations[replicaId] == null
        || RegionInfo.COMPARATOR.compare(location.getRegion(), locations[replicaId].getRegion())
            != 0
        || !location.equals(locations[replicaId])
    ) {
      return this;
    }

    HRegionLocation[] newLocations = new HRegionLocation[locations.length];
    System.arraycopy(locations, 0, newLocations, 0, locations.length);
    newLocations[replicaId] = null;

    return new RegionLocations(newLocations);
  }
Removes the given location from the list
@param location the location to remove
@return an RegionLocations object with removed locations or the same object if nothing is
        removed
hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java