Skip to content

Commit ea52a48

Browse files
committed
fix leak on no more result getmore
1 parent 57d53ad commit ea52a48

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/main/com/mongodb/Response.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@
2525
import org.bson.io.*;
2626

2727
class Response {
28-
28+
2929
Response( DBCollection collection , InputStream in )
3030
throws IOException {
31-
3231
_collection = collection;
3332
_raw = in;
3433

@@ -63,7 +62,12 @@ class Response {
6362
}
6463

6564
void addHook( DoneHook h ){
66-
_hooks.add( h );
65+
if ( _user._toGo == 0 ){
66+
h.done();
67+
}
68+
else {
69+
_hooks.add( h );
70+
}
6771
}
6872

6973
boolean more(){
@@ -119,7 +123,7 @@ public int read()
119123

120124
int val = _in.read();
121125
_toGo--;
122-
126+
123127
if ( _toGo == 0 ){
124128
for ( DoneHook h : _hooks )
125129
h.done();
@@ -159,7 +163,7 @@ public String toString(){
159163
private DBObject _peek;
160164
private int _readSoFar;
161165
private List<DoneHook> _hooks = new LinkedList<DoneHook>();
162-
166+
163167
static interface DoneHook {
164168
void done();
165169
void error( IOException ioe );

src/main/com/mongodb/util/SimplePool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
public abstract class SimplePool<T> {
2424

2525
static final boolean TRACK_LEAKS = Boolean.getBoolean( "MONGO-TRACKLEAKS" );
26-
static long _sleepTime = 15;
26+
static final long _sleepTime = 15;
2727

2828
/**
2929
* See full constructor docs

0 commit comments

Comments
 (0)