Wrap transactions in try-finally.

This commit is contained in:
Greyson Parrelli 2019-04-28 11:41:48 -07:00
parent c0982293bf
commit 5977e9141d

View File

@ -87,6 +87,7 @@ public class JobDatabase extends Database {
db.beginTransaction();
try {
for (FullSpec fullSpec : fullSpecs) {
insertJobSpec(db, fullSpec.getJobSpec());
insertConstraintSpecs(db, fullSpec.getConstraintSpecs());
@ -94,8 +95,10 @@ public class JobDatabase extends Database {
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
public synchronized @NonNull List<JobSpec> getAllJobSpecs() {
List<JobSpec> jobs = new LinkedList<>();
@ -142,6 +145,8 @@ public class JobDatabase extends Database {
SQLiteDatabase db = databaseHelper.getWritableDatabase();
db.beginTransaction();
try {
for (String jobId : jobIds) {
String[] arg = new String[]{jobId};
@ -152,8 +157,10 @@ public class JobDatabase extends Database {
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
public synchronized @NonNull List<ConstraintSpec> getAllConstraintSpecs() {
List<ConstraintSpec> constraints = new LinkedList<>();