ContainX / openstack4j

A Fluent OpenStack SDK / Client Library for Java
http://openstack4j.com
Other
288 stars 368 forks source link

Why OSClientSession is ThreadLocal? #1251

Open hossein-nasr opened 5 years ago

hossein-nasr commented 5 years ago

Why OSClientSession is ThreadLocal? Because of that, we can not use the client in multiple threads easily. There is a guide about how to copy client in for multiple threads but this could raise multiple problems. for example, when must always get token from the main client and if that token has been expired(which is after 24 hours), we always need to reauthenticate at any request! because we create Client from expired token! I believe that OSClientSession should not be thread local.

marvel00000 commented 5 years ago

you can get OSClientSession from a util class,and the util class need to storage OSClientSession to a cache (for example com.google.common.cache.CacheBuilder)。