[JDBC-11] Transaction not rolled back on Throwable exception Created: 03/Jul/11 Updated: 17/Jul/11 Resolved: 17/Jul/11 |
|
| Status: | Resolved |
| Project: | java.jdbc |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | Sean Corfield | Assignee: | Sean Corfield |
| Resolution: | Completed | Votes: | 1 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
(transaction Reported by Sebastián Galkin on github. Transactions rollback on Exception but not Throwable. |
| Comments |
| Comment by Sebastián Bernardo Galkin [ 03/Jul/11 11:07 PM ] |
|
I think the correct behavior would be to call rollback on the transaction and not just not calling commit? The user will expect at the end of the transaction block one of commit or rollback to be called. I was thinking about how to test this. How do you feel about a mock Connection object, where we can check if commit and/or rollback have been called as part of the test? The same mechanism could be used to test other features. |
| Comment by Sebastián Bernardo Galkin [ 04/Jul/11 12:23 AM ] |
|
I was thinking in something like the attached for testing the issue (and other functionality). |
| Comment by Sean Corfield [ 04/Jul/11 12:27 AM ] |
|
FYI, here's the IRC discussion about this, for the record: [5:11pm] <paraseba> |
| Comment by Sebastián Bernardo Galkin [ 09/Jul/11 2:36 PM ] |
|
It's important to realize that there are 2 problems here. a.- Transaction not rolled back on Throwable I think both are equally serious. |
| Comment by Sean Corfield [ 09/Jul/11 3:57 PM ] |
|
I agree Sebastian. I've raised this issue for input from clojure-dev (looking for stylistic guidelines for contrib libraries) because I think both problems need to be fixed. My current leaning is toward supporting three paths:
|
| Comment by Sebastián Bernardo Galkin [ 12/Jul/11 11:05 AM ] |
|
I'm attaching a patch that fixes the problem without adding any tests. |
| Comment by Sean Corfield [ 17/Jul/11 3:28 AM ] |
|
On success, commit unless rollback has been set (in which case rollback). The only two changes here should be:
|