X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fpersisted%2FShardSnapshotState.java;h=a294584227e92765fa84e3ebfe4a6cb6bc9aa5d3;hb=HEAD;hp=3f0b7486767adc76899b099f522eee3b41dc2715;hpb=2dedb8231e13abe55d6b75eb532d23dbe536e168;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardSnapshotState.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardSnapshotState.java index 3f0b748676..c06c5cf318 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardSnapshotState.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardSnapshotState.java @@ -7,15 +7,10 @@ */ package org.opendaylight.controller.cluster.datastore.persisted; -import static com.google.common.base.Verify.verifyNotNull; import static java.util.Objects.requireNonNull; import com.google.common.annotations.VisibleForTesting; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.io.Externalizable; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.raft.persisted.Snapshot; @@ -25,57 +20,7 @@ import org.opendaylight.controller.cluster.raft.persisted.Snapshot; * @author Thomas Pantelis */ public final class ShardSnapshotState implements Snapshot.State { - interface SerialForm extends Externalizable { - - ShardSnapshotState snapshotState(); - - void resolveTo(@NonNull ShardSnapshotState newSnapshotState); - - Object readResolve(); - - @Override - default void readExternal(final ObjectInput in) throws IOException { - resolveTo(ShardDataTreeSnapshot.deserialize(in)); - } - - @Override - default void writeExternal(final ObjectOutput out) throws IOException { - snapshotState().getSnapshot().serialize(out); - } - } - - private static final class Proxy implements SerialForm { - private static final long serialVersionUID = 1L; - - private ShardSnapshotState snapshotState; - - // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't - // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection. - @SuppressWarnings("checkstyle:RedundantModifier") - public Proxy() { - // For Externalizable - } - - Proxy(final ShardSnapshotState snapshotState) { - this.snapshotState = snapshotState; - } - - @Override - public ShardSnapshotState snapshotState() { - return snapshotState; - } - - @Override - public void resolveTo(final ShardSnapshotState newSnapshotState) { - snapshotState = requireNonNull(newSnapshotState); - } - - @Override - public Object readResolve() { - return verifyNotNull(snapshotState); - } - } - + @java.io.Serial private static final long serialVersionUID = 1L; @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "This field is not Serializable but this class " @@ -103,7 +48,8 @@ public final class ShardSnapshotState implements Snapshot.State { return migrated; } + @java.io.Serial private Object writeReplace() { - return new Proxy(this); + return new SS(this); } }