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

Ariel Isaac commented on SHIRO-480:
-----------------------------------

I checked out the method and i think it would also need a refactor since the 
return statement is not needed 
And the code would be something like this 
{code} protected void setTargets(Set<String> targets) {
        if (this.targets == null || !this.targets.equals(targets)) {
            this.targets = targets;
            setParts(domain, actions, targets);
        }
    }
{code}

and makes it more readable

> setTarget method in DomainPermission does not set targets
> ---------------------------------------------------------
>
>                 Key: SHIRO-480
>                 URL: https://issues.apache.org/jira/browse/SHIRO-480
>             Project: Shiro
>          Issue Type: Bug
>          Components: Authorization (access control) 
>    Affects Versions: 1.2.2
>            Reporter: Bill Weiss
>            Priority: Minor
>
> The setTarget() method in org.apache.shiro.authz.permission.DomainPermission 
> has an apparent typo, or copy paste error:
> 133    protected void setTargets(Set<String> targets) {
> 134        this.targets = targets;
> 135        if (this.targets != null && this.targets.equals(targets)) {
> 136            return;
> 137        }
> 138        this.targets = targets;
> 139        setParts(domain, actions, targets);
> 140    }
> As you can see, line 134 is a duplicate of line 138 and will in all cases, 
> except where the argument targets is null, prevent execution from ever 
> calling setParts() and functioning properly.
> The work around for now is for classes extending DomainPermission to handle 
> the call to setParts() directly.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to