Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.lang.ref.WeakReference;
import java.lang.reflect.Method;
import java.sql.Statement;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -49,11 +50,13 @@ public StatementFinalizer() {
}

private boolean logCreationStack = false;
private int createStatementCount=0;
Comment thread
Fisherman110 marked this conversation as resolved.

@Override
public Object createStatement(Object proxy, Method method, Object[] args, Object statement, long time) {
try {
if (statement instanceof Statement) {
clearEntry();
statements.add(new StatementEntry((Statement)statement));
}
}catch (ClassCastException x) {
Expand Down Expand Up @@ -102,9 +105,22 @@ public void reset(ConnectionPool parent, PooledConnection con) {
super.reset(parent, con);
}

/**
* Entry that tracks a statement and its allocation stack.
*/

public void clearEntry() {
if(createStatementCount%10!=0) {
Comment thread
Fisherman110 marked this conversation as resolved.
createStatementCount++;
return;
}else {
createStatementCount=0;
statements.removeIf(entry -> {
Statement stmt = entry.getStatement();
return stmt == null || stmt.isClosed();
});

}
}


protected class StatementEntry {
private WeakReference<Statement> statement;
private Throwable allocationStack;
Expand Down