From f9c14aad141599ede89ec55dca206fbe33d1ca55 Mon Sep 17 00:00:00 2001 From: Graham Date: Wed, 2 Sep 2020 20:25:46 +0100 Subject: [PATCH] Remove redundant rollback after a successful commit No functional change, but I suspect this might remove a database round trip. Signed-off-by: Graham --- db/src/main/java/dev/openrs2/db/Database.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/db/src/main/java/dev/openrs2/db/Database.kt b/db/src/main/java/dev/openrs2/db/Database.kt index 7d3fc8239f..26edba1a9d 100644 --- a/db/src/main/java/dev/openrs2/db/Database.kt +++ b/db/src/main/java/dev/openrs2/db/Database.kt @@ -85,13 +85,16 @@ public class Database( connection.autoCommit = false try { - try { - val result = transaction.execute(connection) - connection.commit() - return result - } finally { + val result = try { + transaction.execute(connection) + } catch (t: Throwable) { connection.rollback() + throw t } + + connection.commit() + + return result } finally { connection.autoCommit = oldAutoCommit }