Fix for Issue 35 Connection pool leak with findFutureRowCount(),

findFutureList() and findFutureIds()
This commit is contained in:
Robin Bygrave
2013-07-01 20:17:38 +12:00
parent c0b83b939d
commit 243864fef7
11 changed files with 216 additions and 65 deletions
@@ -4,25 +4,34 @@ import java.util.concurrent.FutureTask;
import com.avaje.ebean.FutureRowCount;
import com.avaje.ebean.Query;
import com.avaje.ebean.Transaction;
/**
* Future implementation for the row count query.
*/
public class QueryFutureRowCount<T> extends BaseFuture<Integer> implements FutureRowCount<T> {
private final Query<T> query;
private final CallableQueryRowCount<T> call;
public QueryFutureRowCount(Query<T> query, FutureTask<Integer> futureTask) {
super(futureTask);
this.query = query;
public QueryFutureRowCount(CallableQueryRowCount<T> call ) {
super(new FutureTask<Integer>(call));
this.call = call;
}
public FutureTask<Integer> getFutureTask() {
return futureTask;
}
public Transaction getTransaction() {
return call.transaction;
}
public Query<T> getQuery() {
return query;
return call.query;
}
public boolean cancel(boolean mayInterruptIfRunning) {
query.cancel();
call.query.cancel();
return super.cancel(mayInterruptIfRunning);
}