diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java index 16ff8e753d8..0858eb16a5e 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java @@ -400,11 +400,13 @@ public class ReplicationSourceManager implements ReplicationListener { // synchronized on oldsources to avoid race with NodeFailoverWorker synchronized (this.oldsources) { List previousQueueIds = new ArrayList<>(); - for (ReplicationSourceInterface oldSource : this.oldsources) { + for (Iterator iter = this.oldsources.iterator(); iter + .hasNext();) { + ReplicationSourceInterface oldSource = iter.next(); if (oldSource.getPeerId().equals(peerId)) { previousQueueIds.add(oldSource.getQueueId()); oldSource.terminate(terminateMessage); - this.oldsources.remove(oldSource); + iter.remove(); } } for (String queueId : previousQueueIds) {