fixed MetaData#concreteIndices to throw exception with a single index argument in case allowNoIndices == false and ignoreUnavailable == true
Closes #6137
This commit is contained in:
parent
233aaa63c9
commit
c69c66bb7a
|
@ -654,7 +654,7 @@ public class MetaData implements Iterable<IndexMetaData> {
|
|||
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;
|
||||
|
|
|
@ -129,7 +129,7 @@ public class MetaDataTests extends ElasticsearchTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testIndexOptions_allowUnavailableExpandOpenDisAllowEmpty() {
|
||||
public void testIndexOptions_allowUnavailableExpandOpenDisallowEmpty() {
|
||||
MetaData.Builder mdBuilder = MetaData.builder()
|
||||
.put(indexBuilder("foo"))
|
||||
.put(indexBuilder("foobar"))
|
||||
|
@ -145,18 +145,26 @@ public class MetaDataTests extends ElasticsearchTestCase {
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue