[ 
https://issues.apache.org/jira/browse/SHIRO-751?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Francois Papon updated SHIRO-751:
---------------------------------
    Fix Version/s: 1.6.0

> SimplePrincipalMap and SimplePrincipalCollection throw different exceptions 
> for the same problem
> ------------------------------------------------------------------------------------------------
>
>                 Key: SHIRO-751
>                 URL: https://issues.apache.org/jira/browse/SHIRO-751
>             Project: Shiro
>          Issue Type: Bug
>            Reporter: Hao Zhong
>            Priority: Major
>             Fix For: 1.6.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> When realname is null, SimplePrincipalCollection throws 
> IllegalArgumentException:
>  
> {code:java}
> public void add(Object principal, String realmName) {
>         if (realmName == null) {
>             throw new IllegalArgumentException("realmName argument cannot be 
> null.");
>         }
>         if (principal == null) {
>             throw new IllegalArgumentException("principal argument cannot be 
> null.");
>         }
>         this.cachedToString = null;
>         getPrincipalsLazy(realmName).add(principal);
>     }
> {code}
> For the same problem, SimplePrincipalMap throws NullPointerException:
>  
> {code:java}
> public Object setRealmPrincipal(String realmName, String principalName, 
> Object principal) { 
>  if (realmName == null) { 
>    throw new NullPointerException("realmName argument cannot be null."); 
>  }
>  ...}
>  
> {code}
> IllegalArgumentException seems to be more reasonable, and my code currently 
> catches IllegalArgumentException for this type of the problem. Can the 
> SimplePrincipalMap  be modified to throw IllegalArgumentException?



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to