[keycloak-dev] KeycloakSession question

Stan Silvert ssilvert at redhat.com
Mon Apr 13 08:24:58 EDT 2015


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.


More information about the keycloak-dev mailing list