mongodb/mongo-java-driver — pull request #179 by john-morales (2014-04-15 22:18:30+00:00)
Title: JAVA-1165: ensure array and itcount methods always close server-side cursor

Now ensuring server-side cursor is closed on the following methods:

* `itcount()`
* `length()`
* `toArray()`
* `toArray(int)`

While many of this will exhaust the cursor, and therefore effectively have the cursor closed, it wasn't guaranteed in the event of an IO failure. Added test case asserting the toArray(n) behavior.

*Note:* this change _does_ break a couple potential client code patterns that I could imagine:

1.) clients perform one `toArray(small n)`, search this result for something, and if they did not find it page the cursor using the standard iterator approach, which picked up where `n` left off.
2.) clients repeatedly call `toArray(n)` in a loop, expecting to page this way.

Each of these patterns seem somewhat unintuitive in practice, but I must concede they _could_ exist, and would now be broken.

JIRA: https://jira.mongodb.org/browse/JAVA-1165
CC: @jyemin