Loading core/java/android/database/sqlite/SQLiteConnectionPool.java +10 −0 Original line number Diff line number Diff line Loading @@ -570,6 +570,16 @@ public final class SQLiteConnectionPool implements Closeable { mAvailableNonPrimaryConnections.clear(); } /** * Close non-primary connections that are not currently in use. This method is safe to use * in finalize block as it doesn't throw RuntimeExceptions. */ void closeAvailableNonPrimaryConnectionsAndLogExceptions() { synchronized (mLock) { closeAvailableNonPrimaryConnectionsAndLogExceptionsLocked(); } } // Can't throw. private void closeExcessConnectionsAndLogExceptionsLocked() { int availableCount = mAvailableNonPrimaryConnections.size(); Loading core/java/android/database/sqlite/SQLiteDatabase.java +8 −4 Original line number Diff line number Diff line Loading @@ -1740,7 +1740,8 @@ public final class SQLiteDatabase extends SQLiteClosable { private int executeSql(String sql, Object[] bindArgs) throws SQLException { acquireReference(); try { if (DatabaseUtils.getSqlStatementType(sql) == DatabaseUtils.STATEMENT_ATTACH) { final int statementType = DatabaseUtils.getSqlStatementType(sql); if (statementType == DatabaseUtils.STATEMENT_ATTACH) { boolean disableWal = false; synchronized (mLock) { if (!mHasAttachedDbsLocked) { Loading @@ -1754,11 +1755,14 @@ public final class SQLiteDatabase extends SQLiteClosable { } } SQLiteStatement statement = new SQLiteStatement(this, sql, bindArgs); try { try (SQLiteStatement statement = new SQLiteStatement(this, sql, bindArgs)) { return statement.executeUpdateDelete(); } finally { statement.close(); // If schema was updated, close non-primary connections, otherwise they might // have outdated schema information if (statementType == DatabaseUtils.STATEMENT_DDL) { mConnectionPoolLocked.closeAvailableNonPrimaryConnectionsAndLogExceptions(); } } } finally { releaseReference(); Loading Loading
core/java/android/database/sqlite/SQLiteConnectionPool.java +10 −0 Original line number Diff line number Diff line Loading @@ -570,6 +570,16 @@ public final class SQLiteConnectionPool implements Closeable { mAvailableNonPrimaryConnections.clear(); } /** * Close non-primary connections that are not currently in use. This method is safe to use * in finalize block as it doesn't throw RuntimeExceptions. */ void closeAvailableNonPrimaryConnectionsAndLogExceptions() { synchronized (mLock) { closeAvailableNonPrimaryConnectionsAndLogExceptionsLocked(); } } // Can't throw. private void closeExcessConnectionsAndLogExceptionsLocked() { int availableCount = mAvailableNonPrimaryConnections.size(); Loading
core/java/android/database/sqlite/SQLiteDatabase.java +8 −4 Original line number Diff line number Diff line Loading @@ -1740,7 +1740,8 @@ public final class SQLiteDatabase extends SQLiteClosable { private int executeSql(String sql, Object[] bindArgs) throws SQLException { acquireReference(); try { if (DatabaseUtils.getSqlStatementType(sql) == DatabaseUtils.STATEMENT_ATTACH) { final int statementType = DatabaseUtils.getSqlStatementType(sql); if (statementType == DatabaseUtils.STATEMENT_ATTACH) { boolean disableWal = false; synchronized (mLock) { if (!mHasAttachedDbsLocked) { Loading @@ -1754,11 +1755,14 @@ public final class SQLiteDatabase extends SQLiteClosable { } } SQLiteStatement statement = new SQLiteStatement(this, sql, bindArgs); try { try (SQLiteStatement statement = new SQLiteStatement(this, sql, bindArgs)) { return statement.executeUpdateDelete(); } finally { statement.close(); // If schema was updated, close non-primary connections, otherwise they might // have outdated schema information if (statementType == DatabaseUtils.STATEMENT_DDL) { mConnectionPoolLocked.closeAvailableNonPrimaryConnectionsAndLogExceptions(); } } } finally { releaseReference(); Loading