Skip to content

Commit

Permalink
Prevent NPE due to race between rotation and retention threads (#3640)
Browse files Browse the repository at this point in the history
Refs #3637
Fixes #3494
(cherry picked from commit e73fb0f)
  • Loading branch information
kroepke authored and joschi committed Mar 17, 2017
1 parent 3d0c584 commit dc480ee
Showing 1 changed file with 2 additions and 1 deletion.
Expand Up @@ -27,6 +27,7 @@
import org.slf4j.LoggerFactory;

import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -85,7 +86,7 @@ public void retain(IndexSet indexSet) {
private void runRetention(IndexSet indexSet, Map<String, Set<String>> deflectorIndices, int removeCount) {
final Set<String> orderedIndices = Arrays.stream(indexSet.getManagedIndices())
.filter(indexName -> !indices.isReopened(indexName))
.filter(indexName -> !(deflectorIndices.get(indexName).contains(indexSet.getWriteIndexAlias())))
.filter(indexName -> !(deflectorIndices.getOrDefault(indexName, Collections.emptySet()).contains(indexSet.getWriteIndexAlias())))
.sorted((indexName1, indexName2) -> indexSet.extractIndexNumber(indexName2).orElse(0).compareTo(indexSet.extractIndexNumber(indexName1).orElse(0)))
.collect(Collectors.toCollection(LinkedHashSet::new));
orderedIndices
Expand Down

0 comments on commit dc480ee

Please sign in to comment.