Check arguments of MongoItemReader#setSort

Issue #4014
This commit is contained in:
Edgar Asatryan
2021-10-17 01:10:26 +04:00
committed by Mahmoud Ben Hassine
parent 212b3ce950
commit 2e68451cf3
2 changed files with 16 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -164,6 +164,7 @@ public class MongoItemReader<T> extends AbstractPaginatedDataItemReader<T> imple
* @param sorts map of properties and direction to sort each.
*/
public void setSort(Map<String, Sort.Direction> sorts) {
Assert.notNull(sorts, "Sorts must not be null");
this.sort = convertToSort(sorts);
}
@@ -248,7 +249,7 @@ public class MongoItemReader<T> extends AbstractPaginatedDataItemReader<T> imple
}
private Sort convertToSort(Map<String, Sort.Direction> sorts) {
List<Sort.Order> sortValues = new ArrayList<>();
List<Sort.Order> sortValues = new ArrayList<>(sorts.size());
for (Map.Entry<String, Sort.Direction> curSort : sorts.entrySet()) {
sortValues.add(new Sort.Order(curSort.getValue(), curSort.getKey()));