Uploaded image for project: 'Shiro'
  1. Shiro
  2. SHIRO-751

SimplePrincipalMap and SimplePrincipalCollection throw different exceptions for the same problem

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Resolved
    • None
    • 1.5.3
    • None
    • None

    Description

      When realname is null, SimplePrincipalCollection throws IllegalArgumentException:

       

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

      For the same problem, SimplePrincipalMap throws NullPointerException:

       

      public Object setRealmPrincipal(String realmName, String principalName, Object principal) { 
       if (realmName == null) { 
         throw new NullPointerException("realmName argument cannot be null."); 
       }
       ...}
       
      

      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?

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              haozhong Hao Zhong
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m