From 692f80fa610fb51a0d3505bc1cec007f8f0a4e4c Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Mon, 3 Mar 2014 23:22:55 +0100 Subject: [PATCH] [Bugfix] Don't close unopened connection When a PostgreSQL transaction is opened without any objects being modified or queried, then the connection won't be opened, thus no need to close it. --- .../postgresql/PostgreSqlStrolchTransaction.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/li/strolch/persistence/postgresql/PostgreSqlStrolchTransaction.java b/src/main/java/li/strolch/persistence/postgresql/PostgreSqlStrolchTransaction.java index 16f3a975b..fa4709d26 100644 --- a/src/main/java/li/strolch/persistence/postgresql/PostgreSqlStrolchTransaction.java +++ b/src/main/java/li/strolch/persistence/postgresql/PostgreSqlStrolchTransaction.java @@ -51,11 +51,12 @@ public class PostgreSqlStrolchTransaction extends AbstractTransaction { this.resourceDao.commit(txResult); // then commit the SQL connection - if (this.connection != null) + if (this.connection != null) { this.connection.commit(); - // and close the connection, but not catching, as otherwise we can't rollback in exception case - this.connection.close(); + // and close the connection, but not catching, as otherwise we can't rollback in exception case + this.connection.close(); + } } @Override