On 4/13/2015 8:10 AM, Stian Thorgersen wrote:
DefaultFileConnectionProviderFactory has a single instance of
InMemoryModel and a ReadWriteLock. When creating a DefaultFileConnectionProvider it
obtains a read lock and passes it in to DefaultFileConnectionProvider, which is unlocked
when DefaultFileConnectionProvider is closed. To write the file you could either have a
background thread that does it, or just have DefaultFileConnectionProvider do it. In
either case it should first obtain a write lock on the ReadWriteLock associated with
DefaultFileConnectionProviderFactory. This lock makes sure that there isn't any
sessions changing the model while writing to disk so you don't get inconsistencies.
OK. That's exactly what I was proposing but I wasn't thinking about
java.util.current.locks package, which makes the impl easier. It still
requires that KeycloakSession is always short-lived but it sounds like
that is true. So it should work.