Fix index selection for snapshot restore when non-existent indices are specified (#17715)

This commit is contained in:
Sebastian Utz 2016-04-13 17:25:59 +02:00 committed by Yannick Welsch
parent bf2483e4b3
commit 0b889f1a8f
2 changed files with 4 additions and 2 deletions

View File

@ -52,9 +52,10 @@ public class SnapshotUtils {
boolean add = true;
if (!indexOrPattern.isEmpty()) {
if (availableIndices.contains(indexOrPattern)) {
if (result != null) {
result.add(indexOrPattern);
if (result == null) {
result = new HashSet<>();
}
result.add(indexOrPattern);
continue;
}
if (indexOrPattern.charAt(0) == '+') {

View File

@ -34,6 +34,7 @@ public class SnapshotUtilsTests extends ESTestCase {
assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"*"}, new String[]{"foo", "bar", "baz"});
assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"foo", "bar", "baz"}, new String[]{"foo", "bar", "baz"});
assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"foo"}, new String[]{"foo"});
assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"baz", "not_available"}, new String[]{"baz"});
assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"ba*", "-bar", "-baz"}, new String[]{});
assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"-bar"}, new String[]{"foo", "baz"});
assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"-ba*"}, new String[]{"foo"});