DATAES-753 - Reactive Elasticsearch repository: Bulk update fails on empty entity list.

Original PR: #398
This commit is contained in:
Peter-Josef Meisch 2020-02-26 21:50:42 +01:00 committed by GitHub
parent 6a4a7483aa
commit bf51de3805
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 5 deletions

View File

@ -88,7 +88,7 @@ public interface ReactiveDocumentOperations {
/**
* Index entities under the given {@literal type} in the given {@literal index}. If the {@literal index} is
* {@literal null} or empty the index name provided via entity metadata is used. Same for the {@literal type}.
* {@literal null} or empty the index name provided via entity metadata is used.
*
* @param entities must not be {@literal null}.
* @param index the target index, must not be {@literal null}
@ -104,7 +104,7 @@ public interface ReactiveDocumentOperations {
/**
* Index entities under the given {@literal type} in the given {@literal index}. If the {@literal index} is
* {@literal null} or empty the index name provided via entity metadata is used. Same for the {@literal type}.
* {@literal null} or empty the index name provided via entity metadata is used.
*
* @param entities must not be {@literal null}.
* @param index the target index, must not be {@literal null}

View File

@ -160,6 +160,11 @@ public class ReactiveElasticsearchTemplate implements ReactiveElasticsearchOpera
List<AdaptibleEntity<? extends T>> adaptibleEntities = entityList.stream() //
.map(e -> operations.forEntity(e, converter.getConversionService())) //
.collect(Collectors.toList());
if (adaptibleEntities.isEmpty()) {
return Flux.empty();
}
Iterator<AdaptibleEntity<? extends T>> iterator = adaptibleEntities.iterator();
List<IndexQuery> indexRequests = adaptibleEntities.stream() //
.map(e -> getIndexQuery(e.getBean(), e)) //

View File

@ -811,6 +811,13 @@ public class ReactiveElasticsearchTemplateTests {
.verifyComplete();
}
@Test // DATAES-753
void shouldReturnEmptyFluxOnSaveAllWithEmptyInput() {
template.saveAll(Collections.emptyList(), IndexCoordinates.of(DEFAULT_INDEX)) //
.as(StepVerifier::create) //
.verifyComplete();
}
@Data
@Document(indexName = "marvel")
static class Person {