mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-29 15:22:11 +00:00
Fix IllegalArgumentException when creating custom IndicesOption with empty Option or WildcardState set.
Original Pull Request #2076 Closes #2075
This commit is contained in:
parent
14cc9ea495
commit
f37eec641b
@ -118,6 +118,7 @@ import org.springframework.util.StringUtils;
|
|||||||
* @author Farid Faoudi
|
* @author Farid Faoudi
|
||||||
* @author Peer Mueller
|
* @author Peer Mueller
|
||||||
* @author Sijia Liu
|
* @author Sijia Liu
|
||||||
|
* @author Peter Nowak
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
class RequestFactory {
|
class RequestFactory {
|
||||||
@ -1248,7 +1249,11 @@ class RequestFactory {
|
|||||||
.map(it -> org.elasticsearch.action.support.IndicesOptions.WildcardStates.valueOf(it.name().toUpperCase()))
|
.map(it -> org.elasticsearch.action.support.IndicesOptions.WildcardStates.valueOf(it.name().toUpperCase()))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
return new org.elasticsearch.action.support.IndicesOptions(EnumSet.copyOf(options), EnumSet.copyOf(wildcardStates));
|
return new org.elasticsearch.action.support.IndicesOptions(
|
||||||
|
options.isEmpty() ? EnumSet.noneOf(org.elasticsearch.action.support.IndicesOptions.Option.class)
|
||||||
|
: EnumSet.copyOf(options),
|
||||||
|
wildcardStates.isEmpty() ? EnumSet.noneOf(org.elasticsearch.action.support.IndicesOptions.WildcardStates.class)
|
||||||
|
: EnumSet.copyOf(wildcardStates));
|
||||||
}
|
}
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ import static org.skyscreamer.jsonassert.JSONAssert.*;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
import org.elasticsearch.action.DocWriteRequest;
|
import org.elasticsearch.action.DocWriteRequest;
|
||||||
@ -70,6 +71,7 @@ import org.springframework.lang.Nullable;
|
|||||||
* @author Peer Mueller
|
* @author Peer Mueller
|
||||||
* @author vdisk
|
* @author vdisk
|
||||||
* @author Sijia Liu
|
* @author Sijia Liu
|
||||||
|
* @author Peter Nowak
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
@ExtendWith(MockitoExtension.class)
|
@ExtendWith(MockitoExtension.class)
|
||||||
@ -628,6 +630,20 @@ class RequestFactoryTests {
|
|||||||
assertEquals(expected, json, false);
|
assertEquals(expected, json, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test // #2075
|
||||||
|
@DisplayName("should not fail on empty Option set during toElasticsearchIndicesOptions")
|
||||||
|
void shouldNotFailOnEmptyOptionsOnToElasticsearchIndicesOptions() {
|
||||||
|
assertThat(requestFactory.toElasticsearchIndicesOptions(new IndicesOptions(
|
||||||
|
EnumSet.noneOf(IndicesOptions.Option.class), EnumSet.of(IndicesOptions.WildcardStates.OPEN)))).isNotNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // #2075
|
||||||
|
@DisplayName("should not fail on empty WildcardState set during toElasticsearchIndicesOptions")
|
||||||
|
void shouldNotFailOnEmptyWildcardStatesOnToElasticsearchIndicesOptions() {
|
||||||
|
assertThat(requestFactory.toElasticsearchIndicesOptions(IndicesOptions.STRICT_SINGLE_INDEX_NO_EXPAND_FORBID_CLOSED))
|
||||||
|
.isNotNull();
|
||||||
|
}
|
||||||
|
|
||||||
// region entities
|
// region entities
|
||||||
static class Person {
|
static class Person {
|
||||||
@Nullable
|
@Nullable
|
||||||
|
Loading…
x
Reference in New Issue
Block a user