Skip to content

Commit

Permalink
fixed MetaData#concreteIndices to throw exception with a single index…
Browse files Browse the repository at this point in the history
… argument in case allowNoIndices == false and ignoreUnavailable == true

Closes #6137
  • Loading branch information
javanna committed May 12, 2014
1 parent 7cf8234 commit 930728f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Expand Up @@ -654,7 +654,7 @@ public String[] concreteIndices(String[] aliasesOrIndices, IndicesOptions indice
return aliasesOrIndices;
}
String[] actualLst = aliasAndIndexToIndexMap.getOrDefault(aliasOrIndex, Strings.EMPTY_ARRAY);
if (!indicesOptions.allowNoIndices() && actualLst == null) {
if (actualLst.length == 0 && !indicesOptions.allowNoIndices()) {
throw new IndexMissingException(new Index(aliasOrIndex));
} else {
return actualLst;
Expand Down
Expand Up @@ -129,7 +129,7 @@ public void testIndexOptions_lenient() {
}

@Test
public void testIndexOptions_allowUnavailableExpandOpenDisAllowEmpty() {
public void testIndexOptions_allowUnavailableExpandOpenDisallowEmpty() {
MetaData.Builder mdBuilder = MetaData.builder()
.put(indexBuilder("foo"))
.put(indexBuilder("foobar"))
Expand All @@ -145,18 +145,26 @@ public void testIndexOptions_allowUnavailableExpandOpenDisAllowEmpty() {
assertEquals(1, results.length);
assertEquals("foo", results[0]);

results = md.concreteIndices(new String[]{"bar"}, options);
assertThat(results, emptyArray());
try {
md.concreteIndices(new String[]{"bar"}, options);
fail();
} catch(IndexMissingException e) {
assertThat(e.index().name(), equalTo("bar"));
}

try {
md.concreteIndices(new String[]{"baz*"}, options);
fail();
} catch (IndexMissingException e) {}
} catch (IndexMissingException e) {
assertThat(e.index().name(), equalTo("baz*"));
}

try {
md.concreteIndices(new String[]{"foo", "baz*"}, options);
fail();
} catch (IndexMissingException e) {}
} catch (IndexMissingException e) {
assertThat(e.index().name(), equalTo("baz*"));
}
}

@Test
Expand Down

0 comments on commit 930728f

Please sign in to comment.