Your analysis is correct. The TransactionUtils.writing method is as you
suggested. We put in this workaround as an expedient solution, so you may
have noticed the race condition after (activeTransaction != null) and
before the notification gets recorded.
Another reasonable approach would be to throw an IllegalStateException (or
perhaps a ConcurrentModificationException?) when a notification comes in
while a transaction is in play. This would be similar to the way that the
IllegalStateException is thrown if the someone tries to open a read-write
transaction while in a read-transaction. What do you think? Also, please
let me know if you want me to open a bugzilla for this?