Skip to content
Browse files

fix leak on no more result getmore

  • Loading branch information...
1 parent 57d53ad commit ea52a483862f794987791c9c43a4ad74271efa89 @erh erh committed May 19, 2010
Showing with 10 additions and 6 deletions.
  1. +9 −5 src/main/com/mongodb/Response.java
  2. +1 −1 src/main/com/mongodb/util/SimplePool.java
View
14 src/main/com/mongodb/Response.java
@@ -25,10 +25,9 @@
import org.bson.io.*;
class Response {
-
+
Response( DBCollection collection , InputStream in )
throws IOException {
-
_collection = collection;
_raw = in;
@@ -63,7 +62,12 @@
}
void addHook( DoneHook h ){
- _hooks.add( h );
+ if ( _user._toGo == 0 ){
+ h.done();
+ }
+ else {
+ _hooks.add( h );
+ }
}
boolean more(){
@@ -119,7 +123,7 @@ public int read()
int val = _in.read();
_toGo--;
-
+
if ( _toGo == 0 ){
for ( DoneHook h : _hooks )
h.done();
@@ -159,7 +163,7 @@ public String toString(){
private DBObject _peek;
private int _readSoFar;
private List<DoneHook> _hooks = new LinkedList<DoneHook>();
-
+
static interface DoneHook {
void done();
void error( IOException ioe );
View
2 src/main/com/mongodb/util/SimplePool.java
@@ -23,7 +23,7 @@
public abstract class SimplePool<T> {
static final boolean TRACK_LEAKS = Boolean.getBoolean( "MONGO-TRACKLEAKS" );
- static long _sleepTime = 15;
+ static final long _sleepTime = 15;
/**
* See full constructor docs

0 comments on commit ea52a48

Please sign in to comment.
Something went wrong with that request. Please try again.