Github user ajs6f commented on a diff in the pull request:

    https://github.com/apache/jena/pull/168#discussion_r78070911
  
    --- Diff: 
jena-core/src/main/java/org/apache/jena/graph/impl/TransactionHandlerBase.java 
---
    @@ -36,21 +40,45 @@ public TransactionHandlerBase() {
          */
         @Override
         public Object executeInTransaction(Command c) {
    +        return executeRtn( () -> c.execute() ) ;
    +    }
    +
    +    /* Abort but don't let problems with the transaction system itself 
cause loss of the exception */ 
    +    private void abort(Throwable e) {
    +        try { abort() ; }
    +        catch (Throwable th) { e.addSuppressed(th); }
    +    }
    +    
    +    /**
    +     * Execute the runnable <code>action</code> within a transaction. If 
it completes normally,
    +     * commit the transaction, otherwise abort the transaction.
    +     */
    +    @Override
    +    public void execute( Runnable action ) {
             begin() ;
    -        Object result ;
             try {
    -            result = c.execute() ;
    +            action.run();
                 commit() ;
    -            return result ;
             }
             catch (JenaException e) { abort(e) ; throw e ; }
             catch (Throwable e)     { abort(e) ; throw new JenaException(e) ; }
         }
    -
    -    /* Abort but don't let problems with the transaction system itself 
cause loss of the exception */ 
    -    private void abort(Throwable e) {
    -        try { abort() ; }
    -        catch (Throwable th) { e.addSuppressed(th); }
    +    
    +    /**
    +     * Execute the supplier <code>action</code> within a transaction. If 
it completes normally,
    +     * commit the transaction and return the result, otherwise abort the 
transaction.
    +     */
    +    @Override
    +    public <T> T executeRtn( Supplier<T> action ) {
    +        begin() ;
    +        T result ;
    --- End diff --
    
    I'm just wondering why this isn't 
    ```
    try {
        T result = action.get() ;
        commit() ;
        return result ;
    }
    ```
    i.e. what is the need to declare `result` outside of the `try`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to