Hi,

Uhm.. yeah, ignore this past message?

(I probably should have googled "JTA local transactions" before sending the message).


Sorry!

Thanks,
Marco



08/18/2011 11:32 PM, Marco Rietveld:
Hi,

Apologies if this message is any way inappropriate (wrong place, etc.)

After having read the following code in org.drools.persistence.jta.JtaTransactionManager 1000 times, I realized that there was something a little fishy about the code in JtaTransactionManager.commit() (see code (especially in blue) below).

It seems like the private boolean localTransaction is being used to provide basic (1 level) of transaction nesting -- but that it doesn't do that (no un-nesting) and needs to be fixed.

If anyone wouldn't mind speaking up (on- or off-list) about what exactly the code was meant to do or otherwise what the idea was when the code was written, I'd appreciate it! I obviously have my own ideas, but want to make sure I'm not missing anything.

public void begin() {
    if ( getStatus() == TransactionManager.STATUS_NO_TRANSACTION ) {
        this.localTransaction = true;
        try {
            this.ut.begin();
        } catch ( Exception e ) {
            logger.warn( "Unable to begin transaction", e);
            throw new RuntimeException( "Unable to begin transaction",
                                        e );
        }
    } else {
        this.localTransaction = false;
    }
}

public void commit() {
    if ( this.localTransaction ) {
        try {
            this.ut.commit();
        } catch ( Exception e ) {
            logger.warn( "Unable to commit transaction", e);
            throw new RuntimeException( "Unable to commit transaction",
                                        e );
        }
    } else {
        localTransaction = false;
    }

}


(It's not making sense to me why you would set a false boolean to.. false. :) And I have the idea that the else clause was meant to "un-nest" the logical transaction. )

Thanks,
Marco


_______________________________________________
rules-dev mailing list
rules-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev


-- 
Drools/jBPM developer
Utrecht, the Netherlands