Adding guardrails for duplicate shard responses

This commit is contained in:
Joshua Kim 2021-04-29 17:10:55 -07:00
parent 4107b28aba
commit dfed0e3b50

View file

@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -485,10 +486,11 @@ public class KinesisProxy implements IKinesisProxyExtended {
}
} while (response.getStreamDescription().isHasMoreShards());
}
this.cachedShardMap = shards.stream().collect(Collectors.toMap(Shard::getShardId, Function.identity()));
final List<Shard> dedupedShards = new ArrayList<>(new LinkedHashSet<>(shards));
this.cachedShardMap = dedupedShards.stream().collect(Collectors.toMap(Shard::getShardId, Function.identity()));
this.lastCacheUpdateTime = Instant.now();
return shards;
return dedupedShards;
}
/**