X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-akka-raft%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fraft%2Fpersisted%2FUpdateElectionTerm.java;h=99b3b61bad920221959079f2cb101093d071e3d9;hb=8f7f6ed83f1ab21aa9ba1fb2f4f9fbad3a9bfa56;hp=939d893a2ec505538f918a1f30ad5c927c56666a;hpb=e7512222d7d9e3149feb6a90eeb726e9391887fa;p=controller.git diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/UpdateElectionTerm.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/UpdateElectionTerm.java index 939d893a2e..99b3b61bad 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/UpdateElectionTerm.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/UpdateElectionTerm.java @@ -16,11 +16,23 @@ import java.io.Serializable; /** * Message class to persist election term information. */ -public class UpdateElectionTerm implements Serializable { +public sealed class UpdateElectionTerm implements Serializable { + @Deprecated(since = "7.0.0", forRemoval = true) + private static final class Legacy extends UpdateElectionTerm implements LegacySerializable { + @java.io.Serial + private static final long serialVersionUID = 1L; + + Legacy(final long currentTerm, final String votedFor) { + super(currentTerm, votedFor); + } + } + + @Deprecated(since = "7.0.0", forRemoval = true) private static final class Proxy implements Externalizable { + @java.io.Serial private static final long serialVersionUID = 1L; - private UpdateElectionTerm updateElectionTerm; + private UpdateElectionTerm updateElectionTerm = null; // 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. @@ -29,10 +41,6 @@ public class UpdateElectionTerm implements Serializable { // For Externalizable } - Proxy(final UpdateElectionTerm updateElectionTerm) { - this.updateElectionTerm = updateElectionTerm; - } - @Override public void writeExternal(final ObjectOutput out) throws IOException { out.writeLong(updateElectionTerm.currentTerm); @@ -41,14 +49,16 @@ public class UpdateElectionTerm implements Serializable { @Override public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { - updateElectionTerm = new UpdateElectionTerm(in.readLong(), (String) in.readObject()); + updateElectionTerm = new Legacy(in.readLong(), (String) in.readObject()); } + @java.io.Serial private Object readResolve() { return updateElectionTerm; } } + @java.io.Serial private static final long serialVersionUID = 1L; private final long currentTerm; @@ -59,20 +69,21 @@ public class UpdateElectionTerm implements Serializable { this.votedFor = votedFor; } - public long getCurrentTerm() { + public final long getCurrentTerm() { return currentTerm; } - public String getVotedFor() { + public final String getVotedFor() { return votedFor; } - private Object writeReplace() { - return new Proxy(this); + @java.io.Serial + public final Object writeReplace() { + return new UT(this); } @Override - public String toString() { + public final String toString() { return "UpdateElectionTerm [currentTerm=" + currentTerm + ", votedFor=" + votedFor + "]"; } }