I read the document
http://mongodb.github.io/mongo-java-driver/3.4/driver/getting-started/quick-start/#find-all-documents-in-a-collection
and the suggested way is
MongoCursor<Document> cursor = collection.find().iterator();
try {
while (cursor.hasNext()) {
System.out.println(cursor.next().toJson());
}
} finally {
cursor.close();
}
now my questions are:
=
1. is it possbile that the `collection.find().iterator()` create the cursor on server side but client get SOCKET_TIMEOUT before the return of collection.find().iterator() return, so cursor.close failed?
if I change to 'if (cursor != null), it still have cursor leak since cursor is null?
2. will `collection.find().iterator()` to get the real data for the first batch before return?