[JAVA-2894] FindIterable.map().first() does not seem to close the underlying cursor Created: 24/Jun/18  Updated: 28/Oct/23  Resolved: 26/Jun/18

Status: Closed
Project: Java Driver
Component/s: Query Operations
Affects Version/s: 3.7.1
Fix Version/s: 3.8.0

Type: Bug Priority: Major - P3
Reporter: Julien Buret Assignee: Ross Lawley
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

With the current MappingIterable.first() implementation:

 

@Nullable@Overridepublic V first() {
MongoCursor<V> iterator = iterator();
if (!iterator.hasNext()) {
return null;
}
return iterator.next();
}

 

It seems that the MongoCursor.close() method is not called on a col.find().map().first() call.

HTH



 Comments   
Comment by Githook User [ 26/Jun/18 ]

Author:

{'username': 'rozza', 'name': 'Ross Lawley', 'email': 'ross.lawley@gmail.com'}

Message: Ensure MappingIterables delegate to wrapped iterable

JAVA-2894
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/1ff4ce53cfd9376a2cdcbf378a10a00c6e5141a5

Comment by Ross Lawley [ 25/Jun/18 ]

Thanks jburet for the ticket.

We'll look to fix in a forthcoming release.

Ross

Generated at Thu Feb 08 08:58:19 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.