[Commits] Rev 410: CONJ-25 : Close open streaming result sets, when closing connection. in file:///H:/bzr/mariadb-java-client/

Vladislav Vaintroub wlad at montyprogram.com
Thu Feb 14 23:32:41 EET 2013


At file:///H:/bzr/mariadb-java-client/

------------------------------------------------------------
revno: 410
revision-id: wlad at montyprogram.com-20130214213233-c7afc117vtzn5g7b
parent: wlad at montyprogram.com-20130213220529-3nt9agupszq2cufk
fixes bug: https://mariadb.atlassian.net/browse/CONJ-25
committer: Vladislav Vaintroub <wlad at montyprogram.com>
branch nick: mariadb-java-client
timestamp: Thu 2013-02-14 22:32:33 +0100
message:
  CONJ-25 : Close open streaming result sets, when closing connection. 
  
  Prior to this patch a connection would hang during close(), if streaming result set was not fully read.
-------------- next part --------------
=== modified file 'src/main/java/org/mariadb/jdbc/internal/mysql/MySQLProtocol.java'
--- a/src/main/java/org/mariadb/jdbc/internal/mysql/MySQLProtocol.java	2013-02-07 22:13:02 +0000
+++ b/src/main/java/org/mariadb/jdbc/internal/mysql/MySQLProtocol.java	2013-02-14 21:32:33 +0000
@@ -586,6 +586,12 @@ public class MySQLProtocol implements Pr
      */
     public void close()  {
         try {
+            /* If a streaming result set is open, close it.*/ 
+            skip();
+        } catch (Exception e) {
+            /* eat exception */
+        }
+        try {
            close(packetFetcher,writer, socket);
         }
         catch (Exception e) {

=== modified file 'src/test/java/org/mariadb/jdbc/DriverTest.java'
--- a/src/test/java/org/mariadb/jdbc/DriverTest.java	2013-02-13 22:05:29 +0000
+++ b/src/test/java/org/mariadb/jdbc/DriverTest.java	2013-02-14 21:32:33 +0000
@@ -1522,4 +1522,24 @@ public class DriverTest extends BaseTest
                 c.close();
         }
     }
+    
+    @Test
+    public void conj25() throws Exception {
+        String dsn = "jdbc:mysql://localhost:3306/test?user=root";
+        Statement stmt;
+        ResultSet rs;
+        Connection conn = DriverManager.getConnection(dsn);
+        stmt = conn.createStatement();
+        stmt.execute("DROP TABLE IF EXISTS t1");
+        stmt.execute("CREATE TABLE t1 (a VARCHAR(1024))");
+        String st = "INSERT INTO t1 VALUES (REPEAT('a',1024))";
+        for ( int i=1; i<=100; i++) {
+          st = st + ",(REPEAT('a',1024))";
+        }
+        stmt.setFetchSize(Integer.MIN_VALUE);
+        stmt.execute(st);
+        rs = stmt.executeQuery("SELECT * FROM t1 a, t1 b");
+        conn.close();  
+
+    }
 }
\ No newline at end of file



More information about the commits mailing list