Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 39 additions & 39 deletions src/net/sqlcipher/database/SQLiteDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -683,11 +683,11 @@ public void beginTransaction() {
*/
public void beginTransactionWithListener(SQLiteTransactionListener transactionListener) {
lockForced();
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
boolean ok = false;
try {
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
// If this thread already had the lock then get out
if (mLock.getHoldCount() > 1) {
if (mInnerTransactionIsSuccessful) {
Expand Down Expand Up @@ -732,13 +732,13 @@ public void beginTransactionWithListener(SQLiteTransactionListener transactionLi
* @throws IllegalStateException if the database is not open or is not locked by the current thread
*/
public void endTransaction() {
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
if (!mLock.isHeldByCurrentThread()) {
throw new IllegalStateException("no transaction pending");
}
try {
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
if (!mLock.isHeldByCurrentThread()) {
throw new IllegalStateException("no transaction pending");
}
if (mInnerTransactionIsSuccessful) {
mInnerTransactionIsSuccessful = false;
} else {
Expand Down Expand Up @@ -1326,10 +1326,10 @@ private void closeClosable() {
public int getVersion() {
SQLiteStatement prog = null;
lock();
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
try {
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
prog = new SQLiteStatement(this, "PRAGMA user_version;");
long version = prog.simpleQueryForLong();
return (int) version;
Expand Down Expand Up @@ -1359,10 +1359,10 @@ public void setVersion(int version) {
public long getMaximumSize() {
SQLiteStatement prog = null;
lock();
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
try {
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
prog = new SQLiteStatement(this,
"PRAGMA max_page_count;");
long pageCount = prog.simpleQueryForLong();
Expand All @@ -1383,10 +1383,10 @@ public long getMaximumSize() {
public long setMaximumSize(long numBytes) {
SQLiteStatement prog = null;
lock();
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
try {
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
long pageSize = getPageSize();
long numPages = numBytes / pageSize;
// If numBytes isn't a multiple of pageSize, bump up a page
Expand All @@ -1411,10 +1411,10 @@ public long setMaximumSize(long numBytes) {
public long getPageSize() {
SQLiteStatement prog = null;
lock();
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
try {
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
prog = new SQLiteStatement(this,
"PRAGMA page_size;");
long size = prog.simpleQueryForLong();
Expand Down Expand Up @@ -1582,10 +1582,10 @@ public static String findEditTable(String tables) {
*/
public SQLiteStatement compileStatement(String sql) throws SQLException {
lock();
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
try {
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
return new SQLiteStatement(this, sql);
} finally {
unlock();
Expand Down Expand Up @@ -2110,11 +2110,11 @@ public long insertWithOnConflict(String table, String nullColumnHack,
*/
public int delete(String table, String whereClause, String[] whereArgs) {
lock();
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
SQLiteStatement statement = null;
try {
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
statement = compileStatement("DELETE FROM " + table
+ (!TextUtils.isEmpty(whereClause)
? " WHERE " + whereClause : ""));
Expand Down Expand Up @@ -2200,11 +2200,11 @@ public int updateWithOnConflict(String table, ContentValues values,
}

lock();
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
SQLiteStatement statement = null;
try {
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
statement = compileStatement(sql.toString());

// Bind the values
Expand Down Expand Up @@ -2258,10 +2258,10 @@ public int updateWithOnConflict(String table, ContentValues values,
public void execSQL(String sql) throws SQLException {
long timeStart = SystemClock.uptimeMillis();
lock();
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
try {
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
native_execSQL(sql);
} catch (SQLiteDatabaseCorruptException e) {
onCorruption();
Expand All @@ -2274,10 +2274,10 @@ public void execSQL(String sql) throws SQLException {
public void rawExecSQL(String sql){
long timeStart = SystemClock.uptimeMillis();
lock();
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
try {
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
native_rawExecSQL(sql);
} catch (SQLiteDatabaseCorruptException e) {
onCorruption();
Expand All @@ -2304,11 +2304,11 @@ public void execSQL(String sql, Object[] bindArgs) throws SQLException {
}
long timeStart = SystemClock.uptimeMillis();
lock();
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
SQLiteStatement statement = null;
try {
if (!isOpen()) {
throw new IllegalStateException("database not open");
}
statement = compileStatement(sql);
if (bindArgs != null) {
int numArgs = bindArgs.length;
Expand Down