Skip to content

Commit

Permalink
handle transaction close as closeable
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham1g5 committed Apr 10, 2024
1 parent ca6a5d9 commit d54fe91
Showing 1 changed file with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
import org.commcare.cases.entity.AsyncEntity;
import org.commcare.cases.entity.EntityStorageCache;
import org.commcare.models.database.DbUtil;
import org.commcare.modern.database.TableBuilder;
import org.commcare.models.database.SqlStorage;
import org.commcare.modern.database.DatabaseHelper;
import org.commcare.modern.database.DatabaseIndexingUtils;
import org.commcare.modern.database.TableBuilder;
import org.commcare.modern.util.Pair;
import org.commcare.suite.model.Detail;
import org.commcare.suite.model.DetailField;
Expand Down Expand Up @@ -78,18 +78,10 @@ public Closeable lockCache() {
SQLiteDatabase db = CommCareApplication.instance().getUserDbHandle();
//get the db lock
db.beginTransaction();
return db;
}

public void releaseCache() {
SQLiteDatabase db;
try {
db = CommCareApplication.instance().getUserDbHandle();
return () -> {
db.setTransactionSuccessful();
db.endTransaction();
} catch (SessionUnavailableException e) {
// do nothing
}
};
}

//TODO: We should do some synchronization to make it the case that nothing can hold
Expand Down

0 comments on commit d54fe91

Please sign in to comment.