diff --git a/changelog.html b/changelog.html
index bf90312ac..11f049434 100644
--- a/changelog.html
+++ b/changelog.html
@@ -46,7 +46,8 @@
Next Release at some date
- - [#127] - AAdd endpoint that allows for more than one MUC room to be created with one request
+ - [#137] - Defensively create collections in JAXB getters
+ - [#127] - Add endpoint that allows for more than one MUC room to be created with one request
1.8.3 July 19, 2022
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/entity/AdminEntities.java b/src/java/org/jivesoftware/openfire/plugin/rest/entity/AdminEntities.java
index d8b4b8b3f..eabfa0e1c 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/entity/AdminEntities.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/entity/AdminEntities.java
@@ -20,6 +20,7 @@
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import java.util.ArrayList;
import java.util.List;
@XmlRootElement(name = "admins")
@@ -37,6 +38,9 @@ public AdminEntities(List admins) {
@XmlElement(name = "admin")
@JsonProperty(value = "admins")
public List getAdmins() {
+ if (admins == null) {
+ admins = new ArrayList<>();
+ }
return admins;
}
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/entity/ClusterNodeEntities.java b/src/java/org/jivesoftware/openfire/plugin/rest/entity/ClusterNodeEntities.java
index 60f9d7c15..2fa6a9fb3 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/entity/ClusterNodeEntities.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/entity/ClusterNodeEntities.java
@@ -20,6 +20,7 @@
import javax.annotation.Nonnull;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import java.util.ArrayList;
import java.util.List;
@XmlRootElement(name = "clusterNodes")
@@ -36,6 +37,9 @@ public ClusterNodeEntities(@Nonnull final List clusterNodeEnt
@XmlElement(name = "clusterNode")
@JsonProperty(value = "clusterNodes")
public List getClusterNodeEntities() {
+ if (clusterNodeEntities == null) {
+ clusterNodeEntities = new ArrayList<>();
+ }
return clusterNodeEntities;
}
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/entity/GroupEntities.java b/src/java/org/jivesoftware/openfire/plugin/rest/entity/GroupEntities.java
index d7f86bc3c..3011689bf 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/entity/GroupEntities.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/entity/GroupEntities.java
@@ -18,6 +18,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
@@ -56,6 +57,9 @@ public GroupEntities(List groups) {
@XmlElement(name = "group")
@JsonProperty(value = "groups")
public List getGroups() {
+ if (groups == null) {
+ groups = new ArrayList<>();
+ }
return groups;
}
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/entity/GroupEntity.java b/src/java/org/jivesoftware/openfire/plugin/rest/entity/GroupEntity.java
index 277e3448f..0d4945d6b 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/entity/GroupEntity.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/entity/GroupEntity.java
@@ -20,6 +20,7 @@
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Schema;
+import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@@ -121,6 +122,9 @@ public void setDescription(String description) {
@JsonProperty(value = "admins")
@ArraySchema(schema = @Schema(example = "jane.smith"), arraySchema = @Schema(description = "List of admins of the group"))
public List getAdmins() {
+ if (admins == null) {
+ admins = new ArrayList<>();
+ }
return admins;
}
@@ -134,6 +138,9 @@ public List getAdmins() {
@JsonProperty(value = "members")
@ArraySchema(schema = @Schema(example = "john.jones"), arraySchema = @Schema(description = "List of members of the group"))
public List getMembers() {
+ if (members == null) {
+ members = new ArrayList<>();
+ }
return members;
}
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/entity/MUCRoomEntities.java b/src/java/org/jivesoftware/openfire/plugin/rest/entity/MUCRoomEntities.java
index c3d00ed62..d012a5140 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/entity/MUCRoomEntities.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/entity/MUCRoomEntities.java
@@ -18,6 +18,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
@@ -37,6 +38,9 @@ public MUCRoomEntities(List mucRooms) {
@XmlElement(name = "chatRoom")
@JsonProperty(value = "chatRooms")
public List getMucRooms() {
+ if (mucRooms == null) {
+ mucRooms = new ArrayList<>();
+ }
return mucRooms;
}
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/entity/MUCRoomEntity.java b/src/java/org/jivesoftware/openfire/plugin/rest/entity/MUCRoomEntity.java
index 78d07d16e..bb992c5f4 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/entity/MUCRoomEntity.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/entity/MUCRoomEntity.java
@@ -17,7 +17,9 @@
package org.jivesoftware.openfire.plugin.rest.entity;
import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -259,6 +261,9 @@ public void setModerated(boolean moderated) {
@XmlElementWrapper(name = "broadcastPresenceRoles")
@JsonProperty(value = "broadcastPresenceRoles")
public List getBroadcastPresenceRoles() {
+ if (broadcastPresenceRoles == null) {
+ broadcastPresenceRoles = new ArrayList<>();
+ }
return broadcastPresenceRoles;
}
@@ -266,6 +271,9 @@ public List getBroadcastPresenceRoles() {
@XmlElement(name = "owner")
@JsonProperty(value = "owners")
public List getOwners() {
+ if (owners == null) {
+ owners = new ArrayList<>();
+ }
return owners;
}
@@ -273,6 +281,9 @@ public List getOwners() {
@XmlElement(name = "ownerGroup")
@JsonProperty(value = "ownerGroups")
public List getOwnerGroups() {
+ if (ownerGroups == null) {
+ ownerGroups = new ArrayList<>();
+ }
return ownerGroups;
}
@@ -288,6 +299,9 @@ public void setOwnerGroups(List ownerGroups) {
@XmlElement(name = "member")
@JsonProperty(value = "members")
public List getMembers() {
+ if (members == null) {
+ members = new ArrayList<>();
+ }
return members;
}
@@ -295,6 +309,9 @@ public List getMembers() {
@XmlElement(name = "memberGroup")
@JsonProperty(value = "memberGroups")
public List getmemberGroups() {
+ if (memberGroups == null) {
+ memberGroups = new ArrayList<>();
+ }
return memberGroups;
}
@@ -310,6 +327,9 @@ public void setMemberGroups(List memberGroups) {
@XmlElement(name = "outcast")
@JsonProperty(value = "outcasts")
public List getOutcasts() {
+ if (outcasts == null) {
+ outcasts = new ArrayList<>();
+ }
return outcasts;
}
@@ -317,6 +337,9 @@ public List getOutcasts() {
@XmlElement(name = "outcastGroup")
@JsonProperty(value = "outcastGroups")
public List getoutcastGroups() {
+ if (outcastGroups == null) {
+ outcastGroups = new ArrayList<>();
+ }
return outcastGroups;
}
@@ -332,6 +355,9 @@ public void setOutcastGroups(List outcastGroups) {
@XmlElement(name = "admin")
@JsonProperty(value = "admins")
public List getAdmins() {
+ if (admins == null) {
+ admins = new ArrayList<>();
+ }
return admins;
}
@@ -339,6 +365,9 @@ public List getAdmins() {
@XmlElement(name = "adminGroup")
@JsonProperty(value = "adminGroups")
public List getadminGroups() {
+ if (adminGroups == null) {
+ adminGroups = new ArrayList<>();
+ }
return adminGroups;
}
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/entity/MUCRoomMessageEntities.java b/src/java/org/jivesoftware/openfire/plugin/rest/entity/MUCRoomMessageEntities.java
index abbbaaf4d..7b2adb5d9 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/entity/MUCRoomMessageEntities.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/entity/MUCRoomMessageEntities.java
@@ -18,6 +18,7 @@
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import java.util.ArrayList;
import java.util.List;
@XmlRootElement(name = "messages")
@@ -33,6 +34,9 @@ public MUCRoomMessageEntities(List messages) {
@XmlElement(name = "message")
public List getMessages() {
+ if (messages == null) {
+ messages = new ArrayList<>();
+ }
return messages;
}
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/entity/MemberEntities.java b/src/java/org/jivesoftware/openfire/plugin/rest/entity/MemberEntities.java
index 8be254b4b..494354aee 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/entity/MemberEntities.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/entity/MemberEntities.java
@@ -20,6 +20,7 @@
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import java.util.ArrayList;
import java.util.List;
@XmlRootElement(name = "members")
@@ -37,6 +38,9 @@ public MemberEntities(List members) {
@XmlElement(name = "member")
@JsonProperty(value = "members")
public List getMembers() {
+ if (members == null) {
+ members = new ArrayList<>();
+ }
return members;
}
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/entity/OccupantEntities.java b/src/java/org/jivesoftware/openfire/plugin/rest/entity/OccupantEntities.java
index 3d4b9b978..45a26d9a6 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/entity/OccupantEntities.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/entity/OccupantEntities.java
@@ -20,6 +20,7 @@
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import java.util.ArrayList;
import java.util.List;
@XmlRootElement(name = "occupants")
@@ -36,6 +37,9 @@ public OccupantEntities(List occupants) {
@XmlElement(name = "occupant")
@JsonProperty(value = "occupants")
public List getOccupants() {
+ if (occupants == null) {
+ occupants = new ArrayList<>();
+ }
return occupants;
}
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/entity/OutcastEntities.java b/src/java/org/jivesoftware/openfire/plugin/rest/entity/OutcastEntities.java
index 35d676bc6..aee073639 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/entity/OutcastEntities.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/entity/OutcastEntities.java
@@ -20,6 +20,7 @@
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import java.util.ArrayList;
import java.util.List;
@XmlRootElement(name = "outcasts")
@@ -37,6 +38,9 @@ public OutcastEntities(List outcasts) {
@XmlElement(name = "outcast")
@JsonProperty(value = "outcasts")
public List getOutcasts() {
+ if (outcasts == null) {
+ outcasts = new ArrayList<>();
+ }
return outcasts;
}
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/entity/OwnerEntities.java b/src/java/org/jivesoftware/openfire/plugin/rest/entity/OwnerEntities.java
index 413d2dd2d..1b91620e7 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/entity/OwnerEntities.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/entity/OwnerEntities.java
@@ -20,6 +20,7 @@
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import java.util.ArrayList;
import java.util.List;
@XmlRootElement(name = "owners")
@@ -37,6 +38,9 @@ public OwnerEntities(List owners) {
@XmlElement(name = "owner")
@JsonProperty(value = "owners")
public List getOwners() {
+ if (owners == null) {
+ owners = new ArrayList<>();
+ }
return owners;
}
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/entity/ParticipantEntities.java b/src/java/org/jivesoftware/openfire/plugin/rest/entity/ParticipantEntities.java
index 6003a4df3..c4c183b0e 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/entity/ParticipantEntities.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/entity/ParticipantEntities.java
@@ -18,6 +18,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
@@ -37,6 +38,9 @@ public ParticipantEntities(List participants) {
@XmlElement(name = "participant")
@JsonProperty(value = "participants")
public List getParticipants() {
+ if (participants == null) {
+ participants = new ArrayList<>();
+ }
return participants;
}
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/entity/RoomCreationResultEntities.java b/src/java/org/jivesoftware/openfire/plugin/rest/entity/RoomCreationResultEntities.java
index db18e0662..545a1681c 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/entity/RoomCreationResultEntities.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/entity/RoomCreationResultEntities.java
@@ -68,6 +68,9 @@ public void addResult(RoomCreationResultEntity resultToAdd) {
@JsonProperty(value = "success")
@Schema(description = "All creation results of type success")
public List getSuccessResults() {
+ if (successResults == null) {
+ successResults = new ArrayList<>();
+ }
return successResults;
}
@@ -76,6 +79,9 @@ public List getSuccessResults() {
@JsonProperty(value = "failure")
@Schema(description = "All creation results of type failure")
public List getFailureResults() {
+ if (failureResults == null) {
+ failureResults = new ArrayList<>();
+ }
return failureResults;
}
@@ -84,6 +90,9 @@ public List getFailureResults() {
@JsonProperty(value = "other")
@Schema(description = "All creation results of a type other than success or failure")
public List getOtherResults() {
+ if (otherResults == null) {
+ otherResults = new ArrayList<>();
+ }
return otherResults;
}
}
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/entity/RosterEntities.java b/src/java/org/jivesoftware/openfire/plugin/rest/entity/RosterEntities.java
index 42f516d09..b5c490d67 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/entity/RosterEntities.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/entity/RosterEntities.java
@@ -16,6 +16,7 @@
package org.jivesoftware.openfire.plugin.rest.entity;
+import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
@@ -54,6 +55,9 @@ public RosterEntities(List roster) {
*/
@XmlElement(name = "rosterItem")
public List getRoster() {
+ if (roster == null) {
+ roster = new ArrayList<>();
+ }
return roster;
}
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/entity/RosterItemEntity.java b/src/java/org/jivesoftware/openfire/plugin/rest/entity/RosterItemEntity.java
index a2606cfac..62f592a80 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/entity/RosterItemEntity.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/entity/RosterItemEntity.java
@@ -18,6 +18,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
@@ -136,6 +137,9 @@ public void setSubscriptionType(int subscriptionType) {
@XmlElementWrapper(name = "groups")
@JsonProperty(value = "groups")
public List getGroups() {
+ if (groups == null) {
+ groups = new ArrayList<>();
+ }
return groups;
}
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/entity/SecurityAuditLogs.java b/src/java/org/jivesoftware/openfire/plugin/rest/entity/SecurityAuditLogs.java
index ac415f85f..3afef0065 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/entity/SecurityAuditLogs.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/entity/SecurityAuditLogs.java
@@ -18,6 +18,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
@@ -37,8 +38,11 @@ public SecurityAuditLogs(List securityAuditLog) {
@XmlElement(name = "log")
@JsonProperty(value = "logs")
public List getSecurityAuditLog() {
- return securityAuditLog;
- }
+ if (securityAuditLog == null) {
+ securityAuditLog = new ArrayList<>();
+ }
+ return securityAuditLog;
+ }
public void setSecurityAuditLog(List securityAuditLog) {
this.securityAuditLog = securityAuditLog;
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/entity/SessionEntities.java b/src/java/org/jivesoftware/openfire/plugin/rest/entity/SessionEntities.java
index 1d6699523..5a3f75ffd 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/entity/SessionEntities.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/entity/SessionEntities.java
@@ -18,6 +18,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
@@ -37,6 +38,9 @@ public SessionEntities(List sessions) {
@XmlElement(name = "session")
@JsonProperty(value = "sessions")
public List getSessions() {
+ if (sessions == null) {
+ sessions = new ArrayList<>();
+ }
return sessions;
}
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/entity/SystemProperties.java b/src/java/org/jivesoftware/openfire/plugin/rest/entity/SystemProperties.java
index e8ca969f0..490540700 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/entity/SystemProperties.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/entity/SystemProperties.java
@@ -16,6 +16,7 @@
package org.jivesoftware.openfire.plugin.rest.entity;
+import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
@@ -44,6 +45,9 @@ public SystemProperties() {
*/
@XmlElement(name = "property")
public List getProperties() {
+ if (properties == null) {
+ properties = new ArrayList<>();
+ }
return properties;
}
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/entity/UserEntities.java b/src/java/org/jivesoftware/openfire/plugin/rest/entity/UserEntities.java
index dba05f60c..cf94ca349 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/entity/UserEntities.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/entity/UserEntities.java
@@ -18,6 +18,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
@@ -57,6 +58,9 @@ public UserEntities(List users) {
@XmlElement(name = "user")
@JsonProperty(value = "users")
public List getUsers() {
+ if (users == null) {
+ users = new ArrayList<>();
+ }
return users;
}
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/entity/UserEntity.java b/src/java/org/jivesoftware/openfire/plugin/rest/entity/UserEntity.java
index 223257889..fc5eced34 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/entity/UserEntity.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/entity/UserEntity.java
@@ -18,6 +18,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
@@ -158,6 +159,9 @@ public void setPassword(String password) {
@XmlElementWrapper(name = "properties")
@JsonProperty(value = "properties")
public List getProperties() {
+ if (properties == null) {
+ properties = new ArrayList<>();
+ }
return properties;
}
diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/entity/UserGroupsEntity.java b/src/java/org/jivesoftware/openfire/plugin/rest/entity/UserGroupsEntity.java
index f507c70bf..645772103 100644
--- a/src/java/org/jivesoftware/openfire/plugin/rest/entity/UserGroupsEntity.java
+++ b/src/java/org/jivesoftware/openfire/plugin/rest/entity/UserGroupsEntity.java
@@ -18,6 +18,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
@@ -58,6 +59,9 @@ public UserGroupsEntity(List groupNames) {
@XmlElement(name = "groupname")
@JsonProperty(value = "groupnames")
public List getGroupNames() {
+ if (groupNames == null) {
+ groupNames = new ArrayList<>();
+ }
return groupNames;
}