diff --git a/mailbox-core/src/main/java/org/briarproject/mailbox/core/db/JdbcDatabase.kt b/mailbox-core/src/main/java/org/briarproject/mailbox/core/db/JdbcDatabase.kt index b46c2d3409b5dbade799c805863fe47b0ece68ee..b907191fc10b505e5048dab19c4b78f46f2627a0 100644 --- a/mailbox-core/src/main/java/org/briarproject/mailbox/core/db/JdbcDatabase.kt +++ b/mailbox-core/src/main/java/org/briarproject/mailbox/core/db/JdbcDatabase.kt @@ -353,7 +353,7 @@ abstract class JdbcDatabase(private val dbTypes: DatabaseTypes, private val cloc @Throws(DbException::class) override fun getSettings(txn: Transaction, namespace: String): Settings { - val connection: Connection = txn.unbox() as Connection + val connection: Connection = txn.unbox() return getSettings(connection, namespace) } @@ -384,7 +384,7 @@ abstract class JdbcDatabase(private val dbTypes: DatabaseTypes, private val cloc @Throws(DbException::class) override fun mergeSettings(txn: Transaction, s: Settings, namespace: String) { - val connection: Connection = txn.unbox() as Connection + val connection: Connection = txn.unbox() mergeSettings(connection, s, namespace) } @@ -442,7 +442,7 @@ abstract class JdbcDatabase(private val dbTypes: DatabaseTypes, private val cloc @Throws(DbException::class) override fun addContact(txn: Transaction, contact: Contact) { - val connection: Connection = txn.unbox() as Connection + val connection: Connection = txn.unbox() var ps: PreparedStatement? = null try { val sql = """INSERT INTO contacts (contactId, token, inbox, outbox) @@ -464,7 +464,7 @@ abstract class JdbcDatabase(private val dbTypes: DatabaseTypes, private val cloc @Throws(DbException::class) override fun getContact(txn: Transaction, id: Int): Contact? { - val connection: Connection = txn.unbox() as Connection + val connection: Connection = txn.unbox() var ps: PreparedStatement? = null var rs: ResultSet? = null try { @@ -490,7 +490,7 @@ abstract class JdbcDatabase(private val dbTypes: DatabaseTypes, private val cloc @Throws(DbException::class) override fun removeContact(txn: Transaction, id: Int) { - val connection: Connection = txn.unbox() as Connection + val connection: Connection = txn.unbox() var ps: PreparedStatement? = null try { val sql = "DELETE FROM contacts WHERE contactId = ?" @@ -510,7 +510,7 @@ abstract class JdbcDatabase(private val dbTypes: DatabaseTypes, private val cloc */ @Throws(DbException::class) private fun commitTransaction(txn: Transaction) { - val connection: Connection = txn.unbox() as Connection + val connection: Connection = txn.unbox() check(!txn.isCommitted) txn.setCommitted() commitTransaction(connection) @@ -524,7 +524,7 @@ abstract class JdbcDatabase(private val dbTypes: DatabaseTypes, private val cloc */ private fun endTransaction(txn: Transaction) { try { - val connection: Connection = txn.unbox() as Connection + val connection: Connection = txn.unbox() if (!txn.isCommitted) { abortTransaction(connection) } diff --git a/mailbox-core/src/main/java/org/briarproject/mailbox/core/db/Transaction.kt b/mailbox-core/src/main/java/org/briarproject/mailbox/core/db/Transaction.kt index 81176661a8f34e4d72cc40f9c5860be56ba19748..45c17a37548bffb69b021824c54213bfb69356e1 100644 --- a/mailbox-core/src/main/java/org/briarproject/mailbox/core/db/Transaction.kt +++ b/mailbox-core/src/main/java/org/briarproject/mailbox/core/db/Transaction.kt @@ -17,8 +17,7 @@ class Transaction( private set /** - * Returns the database transaction. The type of the returned object - * depends on the database implementation. + * Returns the database connection. */ fun unbox(): Connection { return txn @@ -26,7 +25,7 @@ class Transaction( /** * Marks the transaction as committed. This method should only be called - * by the DatabaseComponent. It must not be called more than once. + * by the Database. It must not be called more than once. */ fun setCommitted() { check(!isCommitted) diff --git a/mailbox-core/src/test/java/org/briarproject/mailbox/core/db/JdbcDatabaseTest.kt b/mailbox-core/src/test/java/org/briarproject/mailbox/core/db/JdbcDatabaseTest.kt index b711dcb000d1a6138ed7bf1cd3609a2963131d9c..1fb1141181e6392c6765105dfe09e6110581e7df 100644 --- a/mailbox-core/src/test/java/org/briarproject/mailbox/core/db/JdbcDatabaseTest.kt +++ b/mailbox-core/src/test/java/org/briarproject/mailbox/core/db/JdbcDatabaseTest.kt @@ -93,7 +93,7 @@ abstract class JdbcDatabaseTest { merged["baz"] = "qux" var db: Database = open(false) - var txn = db.transaction(false) { txn -> + db.transaction(false) { txn -> // store 'before' db.mergeSettings(txn, before, "namespace") assertEquals(before, db.getSettings(txn, "namespace"))