We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a4fb2df commit f374e16Copy full SHA for f374e16
1 file changed
core/src/main/java/fj/control/db/DbState.java
@@ -94,18 +94,21 @@ public Unit run(final Connection c) throws SQLException {
94
* @throws SQLException in case of a database error.
95
*/
96
public <A> A run(final DB<A> dba) throws SQLException {
97
- final Connection c = pc.connect();
98
- c.setAutoCommit(false);
99
- try {
100
- final A a = dba.run(c);
+ try (Connection c = pc.connect()) {
+ c.setAutoCommit(false);
+ final A a;
+ try {
101
+ a = dba.run(c);
102
+ } catch (RuntimeException | SQLException e) {
103
104
+ c.rollback();
105
+ } catch (Exception re) {
106
+ e.addSuppressed(re);
107
+ }
108
+ throw e;
109
110
terminal.run(c);
111
return a;
- } catch (SQLException e) {
- c.rollback();
- throw e;
- }
- finally {
- c.close();
112
}
113
114
0 commit comments