Bug:
123750718
Test: manual test with test code
Change-Id: I80a9d35f7ad6589b3de0a506780cfe956295dcda
} finally {
execute(success ? "COMMIT" : "ROLLBACK", null, null);
}
+ } catch (SQLiteException ex) {
+ throw ex;
} catch (RuntimeException ex) {
throw new SQLiteException("Failed to change locale for db '" + mConfiguration.label
+ "' to '" + newLocale + "'.", ex);
try {
try {
openInner();
- } catch (SQLiteDatabaseCorruptException ex) {
- onCorruption();
- openInner();
+ } catch (RuntimeException ex) {
+ if (SQLiteDatabaseCorruptException.isCorruptException(ex)) {
+ Log.e(TAG, "Database corruption detected in open()", ex);
+ onCorruption();
+ openInner();
+ } else {
+ throw ex;
+ }
}
} catch (SQLiteException ex) {
Log.e(TAG, "Failed to open database '" + getLabel() + "'.", ex);
public SQLiteDatabaseCorruptException(String error) {
super(error);
}
+
+ /**
+ * @return true if a given {@link Throwable} or any of its inner causes is of
+ * {@link SQLiteDatabaseCorruptException}.
+ *
+ * @hide
+ */
+ public static boolean isCorruptException(Throwable th) {
+ while (th != null) {
+ if (th instanceof SQLiteDatabaseCorruptException) {
+ return true;
+ }
+ th = th.getCause();
+ }
+ return false;
+ }
}