mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 17:27:45 +00:00
Wrap transactions in try-finally.
This commit is contained in:
parent
c0982293bf
commit
5977e9141d
@ -87,6 +87,7 @@ public class JobDatabase extends Database {
|
|||||||
|
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
|
|
||||||
|
try {
|
||||||
for (FullSpec fullSpec : fullSpecs) {
|
for (FullSpec fullSpec : fullSpecs) {
|
||||||
insertJobSpec(db, fullSpec.getJobSpec());
|
insertJobSpec(db, fullSpec.getJobSpec());
|
||||||
insertConstraintSpecs(db, fullSpec.getConstraintSpecs());
|
insertConstraintSpecs(db, fullSpec.getConstraintSpecs());
|
||||||
@ -94,8 +95,10 @@ public class JobDatabase extends Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
db.setTransactionSuccessful();
|
db.setTransactionSuccessful();
|
||||||
|
} finally {
|
||||||
db.endTransaction();
|
db.endTransaction();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized @NonNull List<JobSpec> getAllJobSpecs() {
|
public synchronized @NonNull List<JobSpec> getAllJobSpecs() {
|
||||||
List<JobSpec> jobs = new LinkedList<>();
|
List<JobSpec> jobs = new LinkedList<>();
|
||||||
@ -142,6 +145,8 @@ public class JobDatabase extends Database {
|
|||||||
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
||||||
|
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
|
|
||||||
|
try {
|
||||||
for (String jobId : jobIds) {
|
for (String jobId : jobIds) {
|
||||||
String[] arg = new String[]{jobId};
|
String[] arg = new String[]{jobId};
|
||||||
|
|
||||||
@ -152,8 +157,10 @@ public class JobDatabase extends Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
db.setTransactionSuccessful();
|
db.setTransactionSuccessful();
|
||||||
|
} finally {
|
||||||
db.endTransaction();
|
db.endTransaction();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized @NonNull List<ConstraintSpec> getAllConstraintSpecs() {
|
public synchronized @NonNull List<ConstraintSpec> getAllConstraintSpecs() {
|
||||||
List<ConstraintSpec> constraints = new LinkedList<>();
|
List<ConstraintSpec> constraints = new LinkedList<>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user