Bug 7521: Convert byte[] to ShardManagerSnapshot in DatastoreSnapshot
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / persisted / DatastoreSnapshot.java
index 9eb8a066d554da35cfff472b64a2773d12f5d759..fec44082ecdfee199f532dbf9bdee0be1d2c285c 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.controller.cluster.datastore.persisted;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
@@ -59,7 +58,7 @@ public class DatastoreSnapshot implements Serializable {
         @Override
         public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
             String type = (String)in.readObject();
         @Override
         public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
             String type = (String)in.readObject();
-            byte[] shardManagerSnapshot = (byte[]) in.readObject();
+            ShardManagerSnapshot shardManagerSnapshot = (ShardManagerSnapshot) in.readObject();
 
             int size = in.readInt();
             List<ShardSnapshot> shardSnapshots = new ArrayList<>(size);
 
             int size = in.readInt();
             List<ShardSnapshot> shardSnapshots = new ArrayList<>(size);
@@ -76,13 +75,10 @@ public class DatastoreSnapshot implements Serializable {
     }
 
     private final String type;
     }
 
     private final String type;
-    private final byte[] shardManagerSnapshot;
+    private final ShardManagerSnapshot shardManagerSnapshot;
     private final List<ShardSnapshot> shardSnapshots;
 
     private final List<ShardSnapshot> shardSnapshots;
 
-    @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "Stores a reference to an externally mutable byte[] "
-            + "object but this is OK since this class is merely a DTO and does not process byte[] internally. "
-            + "Also it would be inefficient to create a return copy as the byte[] could be large.")
-    public DatastoreSnapshot(@Nonnull String type, @Nullable byte[] shardManagerSnapshot,
+    public DatastoreSnapshot(@Nonnull String type, @Nullable ShardManagerSnapshot shardManagerSnapshot,
             @Nonnull List<ShardSnapshot> shardSnapshots) {
         this.type = Preconditions.checkNotNull(type);
         this.shardManagerSnapshot = shardManagerSnapshot;
             @Nonnull List<ShardSnapshot> shardSnapshots) {
         this.type = Preconditions.checkNotNull(type);
         this.shardManagerSnapshot = shardManagerSnapshot;
@@ -94,11 +90,8 @@ public class DatastoreSnapshot implements Serializable {
         return type;
     }
 
         return type;
     }
 
-    @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 byte[] internally. "
-            + "Also it would be inefficient to create a return copy as the byte[] could be large.")
     @Nullable
     @Nullable
-    public byte[] getShardManagerSnapshot() {
+    public ShardManagerSnapshot getShardManagerSnapshot() {
         return shardManagerSnapshot;
     }
 
         return shardManagerSnapshot;
     }