Modified:
branches/branch_5_0/connector-j/CHANGES
branches/branch_5_0/connector-j/src/com/mysql/jdbc/Connection.java
branches/branch_5_0/connector-j/src/testsuite/regression/ConnectionRegressionTest.java
trunk/connector-j/CHANGES
trunk/connector-j/src/com/mysql/jdbc/Connection.java
trunk/connector-j/src/testsuite/regression/ConnectionRegressionTest.java
Log:
Fixed BUG#25514 - Timer instance used for Statement.setQueryTimeout()
created per-connection, rather than per-VM, causing memory leak
Modified: branches/branch_5_0/connector-j/CHANGES
===================================================================
--- branches/branch_5_0/connector-j/CHANGES 2007-01-10 01:01:58 UTC (rev 6283)
+++ branches/branch_5_0/connector-j/CHANGES 2007-01-10 16:17:09 UTC (rev 6284)
@@ -49,6 +49,9 @@
- Fixed BUG#21438 - Driver sending nanoseconds to server for timestamps when
using server-side prepared statements, when server expects microseconds.
+
+ - Fixed BUG#25514 - Timer instance used for Statement.setQueryTimeout()
+ created per-connection, rather than per-VM, causing memory leak.
10-20-06 - Version 5.0.4
Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/Connection.java
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/Connection.java 2007-01-10 01:01:58
UTC (rev 6283)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/Connection.java 2007-01-10 16:17:09
UTC (rev 6284)
@@ -1068,6 +1068,8 @@
TRANSACTION_REPEATABLE_READ));
mapTransIsolationNameToValue.put("SERIALIZABLE", new Integer(
TRANSACTION_SERIALIZABLE));
+
+ cancelTimer = new Timer("MySQL Statement timeout timer", false);
}
protected static SQLException appendMessageToException(SQLException sqlEx,
@@ -1438,7 +1440,7 @@
String databaseToConnectTo, String url)
throws SQLException {
this.charsetToNumBytesMap = new HashMap();
- this.cancelTimer = new Timer(true);
+
this.connectionCreationTimeMillis = System.currentTimeMillis();
this.pointOfOrigin = new Throwable();
Modified:
branches/branch_5_0/connector-j/src/testsuite/regression/ConnectionRegressionTest.java
===================================================================
---
branches/branch_5_0/connector-j/src/testsuite/regression/ConnectionRegressionTest.java 2007-01-10
01:01:58 UTC (rev 6283)
+++
branches/branch_5_0/connector-j/src/testsuite/regression/ConnectionRegressionTest.java 2007-01-10
16:17:09 UTC (rev 6284)
@@ -1791,4 +1791,52 @@
}
}
}
+
+ /**
+ * Tests fix for BUG#25514 - Timer instance used for Statement.setQueryTimeout()
+ * created per-connection, rather than per-VM, causing memory leak.
+ *
+ * @throws Exception if the test fails.
+ */
+ public void testBug25514() throws Exception {
+
+ for (int i = 0; i < 10; i++) {
+ getConnectionWithProps(null).close();
+ }
+
+ ThreadGroup root = Thread.currentThread().getThreadGroup().getParent();
+
+ while (root.getParent() != null) {
+ root = root.getParent();
+ }
+
+ int numThreadsNamedTimer = findNamedThreadCount(root, "MySQL Statement timeout timer");
+
+ assertEquals(1, numThreadsNamedTimer);
+ }
+
+ private int findNamedThreadCount(ThreadGroup group, String nameStart) {
+
+ int count = 0;
+
+ int numThreads = group.activeCount();
+ Thread[] threads = new Thread[numThreads*2];
+ numThreads = group.enumerate(threads, false);
+
+ for (int i=0; i<numThreads; i++) {
+ if (threads[i].getName().startsWith(nameStart)) {
+ count++;
+ }
+ }
+
+ int numGroups = group.activeGroupCount();
+ ThreadGroup[] groups = new ThreadGroup[numGroups*2];
+ numGroups = group.enumerate(groups, false);
+
+ for (int i=0; i<numGroups; i++) {
+ count += findNamedThreadCount(groups[i], nameStart);
+ }
+
+ return count;
+ }
}
Modified: trunk/connector-j/CHANGES
===================================================================
--- trunk/connector-j/CHANGES 2007-01-10 01:01:58 UTC (rev 6283)
+++ trunk/connector-j/CHANGES 2007-01-10 16:17:09 UTC (rev 6284)
@@ -45,7 +45,10 @@
- Fixed BUG#21438 - Driver sending nanoseconds to server for timestamps when
using server-side prepared statements, when server expects microseconds.
-
+
+ - Fixed BUG#25514 - Timer instance used for Statement.setQueryTimeout()
+ created per-connection, rather than per-VM, causing memory leak
+
10-20-06 - Version 5.0.4
- Fixed BUG#21379 - column names don't match metadata in cases
Modified: trunk/connector-j/src/com/mysql/jdbc/Connection.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/Connection.java 2007-01-10 01:01:58 UTC (rev
6283)
+++ trunk/connector-j/src/com/mysql/jdbc/Connection.java 2007-01-10 16:17:09 UTC (rev
6284)
@@ -180,6 +180,8 @@
TRANSACTION_REPEATABLE_READ));
mapTransIsolationNameToValue.put("SERIALIZABLE", new Integer(
TRANSACTION_SERIALIZABLE));
+
+ cancelTimer = new Timer("MySQL Statement timeout timer", false);
}
protected static SQLException appendMessageToException(SQLException sqlEx,
@@ -577,7 +579,7 @@
String databaseToConnectTo, String url)
throws SQLException {
this.charsetToNumBytesMap = new HashMap();
- this.cancelTimer = new Timer(true);
+
this.connectionCreationTimeMillis = System.currentTimeMillis();
this.pointOfOrigin = new Throwable();
Modified: trunk/connector-j/src/testsuite/regression/ConnectionRegressionTest.java
===================================================================
--- trunk/connector-j/src/testsuite/regression/ConnectionRegressionTest.java 2007-01-10
01:01:58 UTC (rev 6283)
+++ trunk/connector-j/src/testsuite/regression/ConnectionRegressionTest.java 2007-01-10
16:17:09 UTC (rev 6284)
@@ -1793,4 +1793,52 @@
}
}
}
+
+ /**
+ * Tests fix for BUG#25514 - Timer instance used for Statement.setQueryTimeout()
+ * created per-connection, rather than per-VM, causing memory leak.
+ *
+ * @throws Exception if the test fails.
+ */
+ public void testBug25514() throws Exception {
+
+ for (int i = 0; i < 10; i++) {
+ getConnectionWithProps(null).close();
+ }
+
+ ThreadGroup root = Thread.currentThread().getThreadGroup().getParent();
+
+ while (root.getParent() != null) {
+ root = root.getParent();
+ }
+
+ int numThreadsNamedTimer = findNamedThreadCount(root, "MySQL Statement timeout timer");
+
+ assertEquals(1, numThreadsNamedTimer);
+ }
+
+ private int findNamedThreadCount(ThreadGroup group, String nameStart) {
+
+ int count = 0;
+
+ int numThreads = group.activeCount();
+ Thread[] threads = new Thread[numThreads*2];
+ numThreads = group.enumerate(threads, false);
+
+ for (int i=0; i<numThreads; i++) {
+ if (threads[i].getName().startsWith(nameStart)) {
+ count++;
+ }
+ }
+
+ int numGroups = group.activeGroupCount();
+ ThreadGroup[] groups = new ThreadGroup[numGroups*2];
+ numGroups = group.enumerate(groups, false);
+
+ for (int i=0; i<numGroups; i++) {
+ count += findNamedThreadCount(groups[i], nameStart);
+ }
+
+ return count;
+ }
}
| Thread |
|---|
| • Connector/J commit: r6284 - branches/branch_5_0/connector-j branches/branch_5_0/connector-j/src/com/mysql/jdbc branches/branch_5_0/connector-j/src/tes... | mmatthews | 10 Jan |