From fbcd4ba3672c952a370d73f6e35a85f062684f7a Mon Sep 17 00:00:00 2001 From: Niko Schmuck Date: Fri, 19 Aug 2016 15:45:24 +0200 Subject: [PATCH] DATAMONGO-1476 - Consistently use specified collection name in MongoTemplate.stream(). We now use the specified argument name instead of DBCollection.getName() when invoking ReadDbObjectCallback. Original pull request: #382. --- .../springframework/data/mongodb/core/MongoTemplate.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java index bbb9ffc09..78ccce2cf 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java @@ -138,6 +138,7 @@ import com.mongodb.util.JSONParseException; * @author Chuong Ngo * @author Christoph Strobl * @author Doménique Tilleuil + * @author Niko Schmuck */ @SuppressWarnings("deprecation") public class MongoTemplate implements MongoOperations, ApplicationContextAware { @@ -334,7 +335,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware { * @see org.springframework.data.mongodb.core.MongoOperations#stream(org.springframework.data.mongodb.core.query.Query, java.lang.Class, java.lang.String) */ @Override - public CloseableIterator stream(final Query query, final Class entityType, String collectionName) { + public CloseableIterator stream(final Query query, final Class entityType, final String collectionName) { Assert.notNull(query, "Query must not be null!"); Assert.notNull(entityType, "Entity type must not be null!"); @@ -353,8 +354,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware { DBCursor cursor = collection.find(mappedQuery, mappedFields); QueryCursorPreparer cursorPreparer = new QueryCursorPreparer(query, entityType); - ReadDbObjectCallback readCallback = new ReadDbObjectCallback(mongoConverter, entityType, - collection.getName()); + ReadDbObjectCallback readCallback = new ReadDbObjectCallback(mongoConverter, entityType, collectionName); return new CloseableIterableCursorAdapter(cursorPreparer.prepare(cursor), exceptionTranslator, readCallback); }