Merge pull request #208 from drzhonghao/master
[SHIRO-751] SimplePrincipalMap and SimplePrincipalCollection throw different exceptions for the same problem
diff --git a/core/src/main/java/org/apache/shiro/subject/SimplePrincipalCollection.java b/core/src/main/java/org/apache/shiro/subject/SimplePrincipalCollection.java
index 8332759..15d4a0e 100644
--- a/core/src/main/java/org/apache/shiro/subject/SimplePrincipalCollection.java
+++ b/core/src/main/java/org/apache/shiro/subject/SimplePrincipalCollection.java
@@ -98,10 +98,10 @@
public void add(Object principal, String realmName) {
if (realmName == null) {
- throw new IllegalArgumentException("realmName argument cannot be null.");
+ throw new NullPointerException("realmName argument cannot be null.");
}
if (principal == null) {
- throw new IllegalArgumentException("principal argument cannot be null.");
+ throw new NullPointerException("principal argument cannot be null.");
}
this.cachedToString = null;
getPrincipalsLazy(realmName).add(principal);
@@ -109,10 +109,10 @@
public void addAll(Collection principals, String realmName) {
if (realmName == null) {
- throw new IllegalArgumentException("realmName argument cannot be null.");
+ throw new NullPointerException("realmName argument cannot be null.");
}
if (principals == null) {
- throw new IllegalArgumentException("principals argument cannot be null.");
+ throw new NullPointerException("principals argument cannot be null.");
}
if (principals.isEmpty()) {
throw new IllegalArgumentException("principals argument cannot be an empty collection.");