> Ole Husgaard wrote: > > + // Using the construct > > + // try { > > + // txCapsule.doSomething(); > > + // } catch (NullPointerException ex) { > > + // throw new IllegalStateException("No transaction."); > > + // } > > + // may look like bad programming style, but it is > needed to avoid to > > + // synchronize on these methods. If we used a construct like > > + // if (txCapsule == null) > > + // throw new IllegalStateException("No transaction."); > > + // txCapsule.doSomething(); > > + // we can get spurious NullPointerExceptions when > racing with the > > + // transaction completion. > > + > > > > public void commit() > > throws RollbackException, > > @@ -68,9 +83,11 @@ > > java.lang.IllegalStateException, > > SystemException > > { > > - if( txCapsule == null ) > > + try { > > + txCapsule.commit(); > > + } catch (NullPointerException ex) { > > throw new IllegalStateException("No transaction."); > > - txCapsule.commit(); > > + } > > Interesting... Is this actually faster then synchronizing? Have you > measured it?
How about: public void commit() { final TxCapsule localTxCapsule = txCapsule ; if (localTxCapsule == null) throw new IllegalStateException("No transaction.") ; localTxCapsule.commit() ; } Kev Kevin Conner Orchard Information Systems Limited Newcastle Technopole, Kings Manor Newcastle Upon Tyne, NE1 6PA. United Kingdom Registered in England, Number 1900078 Tel: +44 (0) 191-2032536 Fax: +44 (0) 191 2302515 ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development