From: mmatthews Date: November 1 2007 10:01pm Subject: Connector/J commit: r6656 - branches/branch_5_1/src/com/mysql/jdbc List-Archive: http://lists.mysql.com/commits/36928 Message-Id: <200711012201.lA1M1ufI009888@bk-internal.mysql.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified: branches/branch_5_1/src/com/mysql/jdbc/ServerPreparedStatement.java Log: Use a locally-scoped connection reference after checking for it being closed. Modified: branches/branch_5_1/src/com/mysql/jdbc/ServerPreparedStatement.java =================================================================== --- branches/branch_5_1/src/com/mysql/jdbc/ServerPreparedStatement.java 2007-11-01 03:34:31 UTC (rev 6655) +++ branches/branch_5_1/src/com/mysql/jdbc/ServerPreparedStatement.java 2007-11-01 22:01:56 UTC (rev 6656) @@ -663,7 +663,13 @@ } protected int[] executeBatchSerially(int batchTimeout) throws SQLException { - if (this.connection.isReadOnly()) { + ConnectionImpl locallyScopedConn = this.connection; + + if (locallyScopedConn == null) { + checkClosed(); + } + + if (locallyScopedConn.isReadOnly()) { throw SQLError.createSQLException(Messages .getString("ServerPreparedStatement.2") //$NON-NLS-1$ + Messages.getString("ServerPreparedStatement.3"), //$NON-NLS-1$ @@ -672,7 +678,7 @@ checkClosed(); - synchronized (this.connection.getMutex()) { + synchronized (locallyScopedConn.getMutex()) { clearWarnings(); // Store this for later, we're going to 'swap' them out @@ -703,9 +709,9 @@ CancelTask timeoutTask = null; try { - if (this.connection.getEnableQueryTimeouts() && + if (locallyScopedConn.getEnableQueryTimeouts() && batchTimeout != 0 - && this.connection.versionMeetsMinimum(5, 0, 0)) { + && locallyScopedConn.versionMeetsMinimum(5, 0, 0)) { timeoutTask = new CancelTask(this); ConnectionImpl.getCancelTimer().schedule(timeoutTask, batchTimeout);