Skip to content

Commit 45b2dd8

Browse files
committed
JAVA-467: cur.toString() should not block
1 parent 85f0f75 commit 45b2dd8

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

src/main/com/mongodb/DBCursor.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -673,13 +673,10 @@ public DBCollection getCollection(){
673673

674674
/**
675675
* Gets the Server Address of the server that data is pulled from.
676-
* Note that this information is not available if no data has been retrieved yet.
677-
* Availability is specific to underlying implementation and may vary.
676+
* Note that this information may not be available until hasNext() or next() is called.
678677
* @return
679678
*/
680679
public ServerAddress getServerAddress() {
681-
_check();
682-
683680
if (_it != null && _it instanceof DBApiLayer.Result)
684681
return ((DBApiLayer.Result)_it).getServerAddress();
685682

src/test/com/mongodb/DBCursorTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public void testGetServerAddressQuery() {
6363
for (int i=0; i < 10; i++) c.insert(new BasicDBObject("one", "two"));
6464

6565
final DBCursor cur = c.find();
66+
cur.hasNext();
6667
assertNotNull(cur.getServerAddress());
6768
}
6869

@@ -76,6 +77,7 @@ public void testGetServerAddressQuery1() {
7677
for (int i=0; i < 10; i++) c.insert(new BasicDBObject("one", i));
7778

7879
final DBCursor cur = c.find(new BasicDBObject("one", 9));
80+
cur.hasNext();
7981
assertNotNull(cur.getServerAddress());
8082
}
8183

0 commit comments

Comments
 (0)