+1

On 14/08/2015 16:01, Bryn Cooke (JIRA) wrote:
>     [ 
> https://issues.apache.org/jira/browse/TINKERPOP3-805?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14697051#comment-14697051
>  ] 
>
> Bryn Cooke commented on TINKERPOP3-805:
> ---------------------------------------
>
> Hi I just want to point out a scenario where having an Autoclosable 
> transaction is useful although I appreciate the current semantics of the 
> method within TP may not support this:
>
>
> Ideally I want to be able to do this:
> {code:xml}
> try (Transaction tx = graph.tx()) {
>      //Do stuff
>      tx.commit();
> }
> {code}
>         
> Where 'close' on the transaction is equivalent to calling 'rollback'.
> This ensures that I never accidentally leave a transaction open.
> In the case that an exception is thrown in my code I don't have to worry as 
> the transaction is automatically rolled back.
>
> If we have to use this:
> {code:java}
> try {
>      //Do stuff
>   graph.tx().commit()
> } finally {
>   graph.tx().rollback()
> }
> {code}
> then I always have to remember put a rollback statement in a finally block.
> In the end it doesn't save many characters, but I do remember that there were 
> various issues on the gremlin user groups where folks had forgotten to put a 
> rollback in a finally block and had inadvertently left a transaction open 
> resulting in weird behaviour.
>
>
>> Change Transaction to Not Implement Closeable
>> ---------------------------------------------
>>
>>                 Key: TINKERPOP3-805
>>                 URL: https://issues.apache.org/jira/browse/TINKERPOP3-805
>>             Project: TinkerPop 3
>>          Issue Type: Bug
>>          Components: structure
>>    Affects Versions: 3.0.1-incubating
>>            Reporter: stephen mallette
>>            Assignee: stephen mallette
>>              Labels: breaking
>>
>> As of TINKERPOP3-764 the {{close()}} method and related methods/enum were 
>> deprecated.  This code should be removed and {{Transaction}} should no 
>> longer implement {{Closeable}}.
>
>
> --
> This message was sent by Atlassian JIRA
> (v6.3.4#6332)

Reply via email to