Commits

Sebastian Sdorra committed bc4cf6f

fix possible npe on add method of group

  • Participants
  • Parent commits fae3534

Comments (0)

Files changed (1)

scm-core/src/main/java/sonia/scm/group/Group.java

 //~--- non-JDK imports --------------------------------------------------------
 
 import com.google.common.base.Objects;
+import com.google.common.collect.Lists;
 
 import sonia.scm.BasicPropertiesAware;
 import sonia.scm.ModelObject;
 
 //~--- JDK imports ------------------------------------------------------------
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 @XmlRootElement(name = "groups")
 @XmlAccessorType(XmlAccessType.FIELD)
 public class Group extends BasicPropertiesAware
-        implements ModelObject, Iterable<String>
+  implements ModelObject, Iterable<String>
 {
 
   /** Field description */
   {
     this.type = type;
     this.name = name;
-    this.members = new ArrayList<String>();
+    this.members = Lists.newArrayList();
   }
 
   /**
   {
     this.type = type;
     this.name = name;
-    this.members = new ArrayList<String>();
+    this.members = Lists.newArrayList();
 
     if (Util.isNotEmpty(members))
     {
    */
   public boolean add(String member)
   {
-    return members.add(member);
+    return getMembers().add(member);
   }
 
   /**
     final Group other = (Group) obj;
 
     return Objects.equal(name, other.name)
-           && Objects.equal(description, other.description)
-           && Objects.equal(members, other.members)
-           && Objects.equal(type, other.type)
-           && Objects.equal(creationDate, other.creationDate)
-           && Objects.equal(lastModified, other.lastModified)
-           && Objects.equal(properties, other.properties);
+      && Objects.equal(description, other.description)
+      && Objects.equal(members, other.members)
+      && Objects.equal(type, other.type)
+      && Objects.equal(creationDate, other.creationDate)
+      && Objects.equal(lastModified, other.lastModified)
+      && Objects.equal(properties, other.properties);
   }
 
   /**
   public int hashCode()
   {
     return Objects.hashCode(name, description, members, type, creationDate,
-                            lastModified, properties);
+      lastModified, properties);
   }
 
   /**
   {
     if (members == null)
     {
-      members = new ArrayList<String>();
+      members = Lists.newArrayList();
     }
 
     return members;