diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/PrivacyListManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/PrivacyListManager.java
index 360671031..f0d7e7bb9 100644
--- a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/PrivacyListManager.java
+++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/PrivacyListManager.java
@@ -41,6 +41,7 @@ import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Stanza;
+import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.privacy.filter.SetActiveListFilter;
import org.jivesoftware.smackx.privacy.filter.SetDefaultListFilter;
@@ -267,7 +268,7 @@ public class PrivacyListManager extends Manager {
}
/**
- * Answer the active privacy list.
+ * Answer the active privacy list. Returns null
if there is no active list.
*
* @return the privacy list of the active list.
* @throws XMPPErrorException
@@ -277,6 +278,9 @@ public class PrivacyListManager extends Manager {
public PrivacyList getActiveList() throws NoResponseException, XMPPErrorException, NotConnectedException {
Privacy privacyAnswer = this.getPrivacyWithListNames();
String listName = privacyAnswer.getActiveName();
+ if (StringUtils.isNullOrEmpty(listName)) {
+ return null;
+ }
boolean isDefaultAndActive = listName != null && listName.equals(privacyAnswer.getDefaultName());
return new PrivacyList(true, isDefaultAndActive, listName, getPrivacyListItems(listName));
}
@@ -298,7 +302,7 @@ public class PrivacyListManager extends Manager {
}
/**
- * Answer the default privacy list.
+ * Answer the default privacy list. Returns null
if there is no default list.
*
* @return the privacy list of the default list.
* @throws XMPPErrorException
@@ -308,7 +312,10 @@ public class PrivacyListManager extends Manager {
public PrivacyList getDefaultList() throws NoResponseException, XMPPErrorException, NotConnectedException {
Privacy privacyAnswer = this.getPrivacyWithListNames();
String listName = privacyAnswer.getDefaultName();
- boolean isDefaultAndActive = listName != null && listName.equals(privacyAnswer.getActiveName());
+ if (StringUtils.isNullOrEmpty(listName)) {
+ return null;
+ }
+ boolean isDefaultAndActive = listName.equals(privacyAnswer.getActiveName());
return new PrivacyList(isDefaultAndActive, true, listName, getPrivacyListItems(listName));
}
@@ -359,6 +366,7 @@ public class PrivacyListManager extends Manager {
* @throws NotConnectedException
*/
private List getPrivacyListItems(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException {
+ assert StringUtils.isNotEmpty(listName);
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setPrivacyList(listName, new ArrayList());
@@ -379,6 +387,7 @@ public class PrivacyListManager extends Manager {
* @throws NotConnectedException
*/
public PrivacyList getPrivacyList(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException {
+ listName = StringUtils.requireNotNullOrEmpty(listName, "List name must not be null");
return new PrivacyList(false, false, listName, getPrivacyListItems(listName));
}