Fix FindBugs warnings in sal-akk-raft
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / Snapshot.java
index 3d1976483a96ddde4618ae5f4caa3e69e52bb511..2677baff6da40d1e2caba4a7b257594e5233bb3b 100644 (file)
@@ -7,10 +7,17 @@
  */
 package org.opendaylight.controller.cluster.raft;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.Serializable;
 import java.util.List;
+import org.opendaylight.controller.cluster.raft.persisted.ServerConfigurationPayload;
 
-
+/**
+ * Represents a snapshot of the raft data.
+ *
+ * @author Moiz Raja
+ * @author Thomas Pantelis
+ */
 public class Snapshot implements Serializable {
     private static final long serialVersionUID = -8298574936724056236L;
 
@@ -56,6 +63,9 @@ public class Snapshot implements Serializable {
                 electionTerm, electionVotedFor, serverConfig);
     }
 
+    @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Exposes a mutable object stored in a field but "
+            + "this is OK since this class is merely a DTO and does not process the byte[] internally. "
+            + "Also it would be inefficient to create a return copy as the byte[] could be large.")
     public byte[] getState() {
         return state;
     }
@@ -97,7 +107,7 @@ public class Snapshot implements Serializable {
     public String toString() {
         return "Snapshot [lastIndex=" + lastIndex + ", lastTerm=" + lastTerm + ", lastAppliedIndex=" + lastAppliedIndex
                 + ", lastAppliedTerm=" + lastAppliedTerm + ", unAppliedEntries size=" + unAppliedEntries.size()
-                + ", state size=" + state.length + ", electionTerm=" + electionTerm + ", electionVotedFor=" + electionVotedFor
-                + ", ServerConfigPayload="  + serverConfig + "]";
+                + ", state size=" + state.length + ", electionTerm=" + electionTerm + ", electionVotedFor="
+                + electionVotedFor + ", ServerConfigPayload="  + serverConfig + "]";
     }
 }