[JDBC-47] Transactions do not rollback on non-Exception Throwables Created: 26/Feb/13 Updated: 26/Feb/13 Resolved: 26/Feb/13 |
|
| Status: | Resolved |
| Project: | java.jdbc |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | Gary Fredericks | Assignee: | Sean Corfield |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
0.2.3 |
||
| Attachments: |
|
| Description |
|
transaction* currently catches Exceptions for its rollback logic. This means Throwables subclassing java.lang.Error are not caught, and indeed the transaction seems to be immediately committed in this case (at least if the connection has autocommit set to true). This happened to me in the case of an OutOfMemoryError. Another example is that the following code commits: (transaction
(insert-records "table" {:foo 12})
(assert false))
Presumably this can be fixed by catching Throwable instead of Exception. I'll prepare a patch to that effect. |
| Comments |
| Comment by Sean Corfield [ 26/Feb/13 4:48 PM ] |
|
Thanx Gary. In the latest source there may be two pieces of transaction logic so please check for anywhere else that Exception is mentioned! |
| Comment by Gary Fredericks [ 26/Feb/13 5:17 PM ] |
|
This patch changes Exception to Throwable in two places – transaction* and db-transaction*. The tests pass. |
| Comment by Sean Corfield [ 26/Feb/13 8:08 PM ] |
|
Patch applied. |