[SERVER-19726] Infinite loop Created: 03/Aug/15 Updated: 03/Aug/15 Resolved: 03/Aug/15 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Code |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | James Scott Stanlick | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Operating System: | ALL |
| Participants: |
| Description |
|
The while (cursor.hasNext()) loops indefinitely. collection.count() == 1520 public void queryCollectionAll() { } finally { cursor.close(); System.out.println("collection.count():"+count); } |
| Comments |
| Comment by James Scott Stanlick [ 03/Aug/15 ] |
|
Duh! Thanks guys |
| Comment by Scott Hernandez (Inactive) [ 03/Aug/15 ] |
|
As James alluded to, you need to actually iterate the cursor by getting the next item, else your while loop will never end, since you will always have that same next one available. |
| Comment by James Wahlin [ 03/Aug/15 ] |
|
Try adding a cursor.next() in your while block. You are checking whether a cursor has more data but not advancing the cursor. |