You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shiro.apache.org by "Brian Demers (Jira)" <ji...@apache.org> on 2020/03/28 02:29:00 UTC
[jira] [Commented] (SHIRO-751) SimplePrincipalMap and
SimplePrincipalCollection throw different exceptions for the same problem
[ https://issues.apache.org/jira/browse/SHIRO-751?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17069190#comment-17069190 ]
Brian Demers commented on SHIRO-751:
------------------------------------
Thanks [~haozhong]!
Any chance you want to send a us a PR? :)
https://github.com/apache/shiro
> 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
>
> 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)