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;
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- String type = (String)in.readObject();
- byte[] shardManagerSnapshot = (byte[]) in.readObject();
+ String localType = (String)in.readObject();
+ ShardManagerSnapshot localShardManagerSnapshot = (ShardManagerSnapshot) in.readObject();
int size = in.readInt();
- List<ShardSnapshot> shardSnapshots = new ArrayList<>(size);
+ List<ShardSnapshot> localShardSnapshots = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
- shardSnapshots.add((ShardSnapshot) in.readObject());
+ localShardSnapshots.add((ShardSnapshot) in.readObject());
}
- datastoreSnapshot = new DatastoreSnapshot(type, shardManagerSnapshot, shardSnapshots);
+ datastoreSnapshot = new DatastoreSnapshot(localType, localShardManagerSnapshot, localShardSnapshots);
}
private Object readResolve() {
}
private final String type;
- private final byte[] shardManagerSnapshot;
+ private final ShardManagerSnapshot shardManagerSnapshot;
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;
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
- public byte[] getShardManagerSnapshot() {
+ public ShardManagerSnapshot getShardManagerSnapshot() {
return shardManagerSnapshot;
}
return shardSnapshots;
}
- @SuppressWarnings("static-method")
private Object writeReplace() {
return new Proxy(this);
}
return snapshot;
}
- @SuppressWarnings("static-method")
private Object writeReplace() {
return new Proxy(this);
}