diff options
author | Justin Klaassen <justinklaassen@google.com> | 2017-11-30 18:18:21 -0500 |
---|---|---|
committer | Justin Klaassen <justinklaassen@google.com> | 2017-11-30 18:18:21 -0500 |
commit | 4217cf85c20565a3446a662a7f07f26137b26b7f (patch) | |
tree | a0417b47a8cc802f6642f369fd2371165bec7b5c /android/database | |
parent | 6a65f2da209bff03cb0eb6da309710ac6ee5026d (diff) | |
download | android-28-4217cf85c20565a3446a662a7f07f26137b26b7f.tar.gz |
Import Android SDK Platform P [4477446]
/google/data/ro/projects/android/fetch_artifact \
--bid 4477446 \
--target sdk_phone_armv7-win_sdk \
sdk-repo-linux-sources-4477446.zip
AndroidVersion.ApiLevel has been modified to appear as 28
Change-Id: If0559643d7c328e36aafca98f0c114641d33642c
Diffstat (limited to 'android/database')
-rw-r--r-- | android/database/sqlite/SQLiteConnectionPool.java | 10 | ||||
-rw-r--r-- | android/database/sqlite/SQLiteDatabase.java | 12 |
2 files changed, 18 insertions, 4 deletions
diff --git a/android/database/sqlite/SQLiteConnectionPool.java b/android/database/sqlite/SQLiteConnectionPool.java index 8b0fef4f..5adb1196 100644 --- a/android/database/sqlite/SQLiteConnectionPool.java +++ b/android/database/sqlite/SQLiteConnectionPool.java @@ -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(); diff --git a/android/database/sqlite/SQLiteDatabase.java b/android/database/sqlite/SQLiteDatabase.java index 863fb198..09bb9c69 100644 --- a/android/database/sqlite/SQLiteDatabase.java +++ b/android/database/sqlite/SQLiteDatabase.java @@ -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) { @@ -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(); |