You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shiro.apache.org by "Vesa Jääskeläinen (JIRA)" <ji...@apache.org> on 2014/09/21 10:16:33 UTC
[jira] [Created] (SHIRO-519) ThreadContext.setResources() doesn't
handle empty maps correctly
Vesa Jääskeläinen created SHIRO-519:
---------------------------------------
Summary: ThreadContext.setResources() doesn't handle empty maps correctly
Key: SHIRO-519
URL: https://issues.apache.org/jira/browse/SHIRO-519
Project: Shiro
Issue Type: Bug
Components: Session Management
Affects Versions: 1.2.2, 1.2.3
Reporter: Vesa Jääskeläinen
Priority: Minor
ThreadLocal.setResources() doesn't handle the case where resources is want to be cleared.
This could be used in situation when session is switched temporary to another thread.
One could do:
old = ThreadContext.getResources();
ThreadContext.setResources(new);
// do the magic
ThreadContext.setResources(old);
If the old resources was empty it will leave new resources in place.
Fix would be trivial:
{code}
public static void setResources(Map<Object, Object> newResources) {
if (CollectionUtils.isEmpty(newResources)) {
return;
}
resources.get().clear();
resources.get().putAll(newResources);
}
{code}
->
{code}
public static void setResources(Map<Object, Object> newResources) {
resources.get().clear();
if (CollectionUtils.isEmpty(newResources)) {
return;
}
resources.get().putAll(newResources);
}
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)