]
Ondra Chaloupka reassigned JBTM-2756:
-------------------------------------
Assignee: (was: Ondra Chaloupka)
Static code analysis: nondeterministic locking behavior at
ThreadAssociations#removeAll
---------------------------------------------------------------------------------------
Key: JBTM-2756
URL:
https://issues.jboss.org/browse/JBTM-2756
Project: JBoss Transaction Manager
Issue Type: Bug
Components: JTS
Affects Versions: 5.3.4.Final
Reporter: Ondra Chaloupka
Static code analysis category: Nondeterministic locking behavior
_CID-17602_: Bad choice of lock object - Nondeterministic locking behavior
in class `ThreadAssociations` [1] at method `removeAll`. There is used synchronized
block
where lock is acquired at `globalTxAssociations` and `txAssociations`.
The problem (one for txAssociations is described as)
lock_acquire: Acquiring lock
`com.arjuna.ats.jts.extensions.`ThreadAssociations.txAssociations`.
lock_on_assigned_field: Locking on the object referenced by field
`ThreadAssociations.txAssociations`. This lock acquisition may race with another thread
assigning to this field. The contents of `ThreadAssociations.txAssociations` may change
while a thread is inside the critical section, allowing two threads to enter the critical
section simultaneously.
* Instead of using `ThreadAssociations.txAssociations` as a lock, create a final field
of type Object which is only used as a lock.
assign_to_field: The expression `ThreadAssociations.txAssociations = null` assigns a new
value to `ThreadAssociations.txAssociations`, a field whose contents are used as a lock.
The locking behavior of this function may allow this assignment to occur multiple times.
Tom's reaction on this
{quote}
I think that the bug is that there is any synchronization at all on txAssociations
because it looks to be indexed by Thread.currentThread().
{quote}
[1]
https://github.com/jbosstm/narayana/blob/master/ArjunaJTS/jts/classes/com...