-
Notifications
You must be signed in to change notification settings - Fork 5.4k
fix for Bug 62432 , clear invalid Entry for org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer #941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -49,11 +50,13 @@ public StatementFinalizer() { | |
| } | ||
|
|
||
| private boolean logCreationStack = false; | ||
| private int createStatementCount=0; | ||
|
|
||
| @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) { | ||
|
|
@@ -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) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't you want to check every add?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function clearEntry() is called when a new statement is created and will be add to the list. Check line 50 in StatementFinalizer.java
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clear opration invoked every ten times |
||
| 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; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.