Skip to content

Commit 0470dd6

Browse files
committed
DATAMONGO-1725 - Prevent NullPointerException in CloseableIterableCursorAdapter.close().
1 parent 270d373 commit 0470dd6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2740,8 +2740,13 @@ public T next() {
27402740
public void close() {
27412741

27422742
MongoCursor<Document> c = cursor;
2743+
27432744
try {
2744-
c.close();
2745+
2746+
if (c != null) {
2747+
c.close();
2748+
}
2749+
27452750
} catch (RuntimeException ex) {
27462751
throw potentiallyConvertRuntimeException(ex, exceptionTranslator);
27472752
} finally {

0 commit comments

Comments
 (0)