uberfire/uberfire — pull request #47 by mrietveld (2014-04-24 10:45:39+00:00)
Title: Fix for race condition in ThreadLockServiceImpl

It looks to me like the following race-condition is possible in lines 23 - 35 of
the ThreadLockSerivceImpl class.

Given that we're already using Atomic classes, adding a synchronized doesn't affect
performance at all, if that was a concern.

Thread A | Thread B
------------| ------------
calls `ThreadLockServiceImpl.lock()` |
| calls `ThreadLockServiceImpl.lock()`
`holder.get()` returns `null` |
| `holder.get()` returns `null`
`holder.set( Thread.currentThread() );` |
| `holder.set( Thread.currentThread() );`
`stackSize.set( 1 );` |
| `stackSize.set( 1 );`