DATAMONGO-2330 - Apply defaultWriteConcern for bulk operations.

Fixed regression introduced in DATAMONGO-1880.

Original Pull Request: #775
This commit is contained in:
nkey
2019-07-31 13:50:26 +03:00
committed by Christoph Strobl
parent cb85f3cfa6
commit e6ea2e1379

View File

@@ -58,6 +58,7 @@ import com.mongodb.client.model.WriteModel;
* @author Oliver Gierke * @author Oliver Gierke
* @author Christoph Strobl * @author Christoph Strobl
* @author Mark Paluch * @author Mark Paluch
* @author Michail Nikolaev
* @since 1.9 * @since 1.9
*/ */
class DefaultBulkOperations implements BulkOperations { class DefaultBulkOperations implements BulkOperations {
@@ -276,6 +277,10 @@ class DefaultBulkOperations implements BulkOperations {
try { try {
return mongoOperations.execute(collectionName, collection -> { return mongoOperations.execute(collectionName, collection -> {
if (defaultWriteConcern != null) {
collection = collection.withWriteConcern(defaultWriteConcern);
}
return collection.bulkWrite(models.stream().map(this::mapWriteModel).collect(Collectors.toList()), bulkOptions); return collection.bulkWrite(models.stream().map(this::mapWriteModel).collect(Collectors.toList()), bulkOptions);
}); });
} finally { } finally {