On Oct 16, 2012, at 10:16 AM, Gina Choi <[email protected]> wrote:
> Hi Dan,
>
> Thanks for your tip. Could you explain to me why do we remove the token when
> it is null? I don't know much about ThreadLocal.
Internally, the "Thread" object keeps a map of the ThreadLocal object -> Value.
If you set the value to null, it's still in the map with a null value.
However, if you call remove, it removes the entire thing from the map which
helps make sure there are no threads holding onto anything that could cause jar
locking and such.
It's similar to HashMap behavior. With a HashMap, you can do:
hashMap.set("foo", null);
or
hashMap.remove("foo")
In both cases, a hashMap.get("foo") would return null. However, the first
method would result in a size()==1 has there is a key/value pair in the map.
In the second case, the map is really empty.
Dan
>
> I was thinking the following.
>
> if(token != null){
> TLS.set(token)
> }
>
> Gina
>
>
>
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/Fediz-SSO-Do-we-need-to-unset-token-tp5716524p5716743.html
> Sent from the cxf-user mailing list archive at Nabble.com.
--
Daniel Kulp
[email protected] - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com