shiro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ariel Isaac (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (SHIRO-519) ThreadContext.setResources() doesn't handle empty maps correctly
Date Mon, 05 Oct 2015 22:34:27 GMT

    [ https://issues.apache.org/jira/browse/SHIRO-519?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14944158#comment-14944158
] 

Ariel Isaac commented on SHIRO-519:
-----------------------------------

Hey! i tried your solution and it worked for me.
Thanks!

> 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)

Mime
View raw message