private static Object getLockOwner ( final TransactionSynchronizationRegistry transactionSynchronizationRegistry ) { Object owner = transactionSynchronizationRegistry . getTransactionKey ( ) ; return owner != null ? owner : Thread . currentThread ( ) ; }
Use either the active transaction or the current thread as the lock owner