Remove old unversioned proxies 86/103486/21
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 30 Nov 2022 22:25:28 +0000 (23:25 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 10 May 2023 14:03:01 +0000 (16:03 +0200)
We have a number of unversioned classes which are using two
externalizable proxies. Remove legacy proxies, inlining SerialForm
interfaces.

JIRA: CONTROLLER-2063
Change-Id: If3f96563d1331dc1449bdb87baf55124e78d473a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
13 files changed:
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/CI.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/ClientIdentifier.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/FE.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/FI.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/FT.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/FrontendIdentifier.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/FrontendType.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/HI.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/LocalHistoryIdentifier.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/MN.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/MemberName.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/TI.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/TransactionIdentifier.java

index 2186d03e5a891a4119f111acc46501c929cf77a8..e88764dbedd104e0483aa3486153e22018efd742 100644 (file)
@@ -10,10 +10,16 @@ package org.opendaylight.controller.cluster.access.concepts;
 import static com.google.common.base.Verify.verifyNotNull;
 import static java.util.Objects.requireNonNull;
 
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.opendaylight.yangtools.concepts.WritableObjects;
+
 /**
  * Serialization proxy for {@link ClientIdentifier}.
  */
-final class CI implements ClientIdentifier.SerialForm {
+final class CI implements Externalizable {
     @java.io.Serial
     private static final long serialVersionUID = 1L;
 
@@ -29,17 +35,18 @@ final class CI implements ClientIdentifier.SerialForm {
     }
 
     @Override
-    public ClientIdentifier identifier() {
-        return verifyNotNull(identifier);
+    public void readExternal(final ObjectInput in) throws IOException {
+        identifier = new ClientIdentifier(FrontendIdentifier.readFrom(in), WritableObjects.readLong(in));
     }
 
     @Override
-    public void setIdentifier(final ClientIdentifier identifier) {
-        this.identifier = requireNonNull(identifier);
+    public void writeExternal(final ObjectOutput out) throws IOException {
+        identifier.getFrontendId().writeTo(out);
+        WritableObjects.writeLong(out, identifier.getGeneration());
     }
 
-    @Override
-    public Object readResolve() {
-        return identifier();
+    @java.io.Serial
+    private Object readResolve() {
+        return verifyNotNull(identifier);
     }
 }
index 3468ed6a5d76e729e42e18f12e44c6233a4f4b06..42701539a6170a0f48942fa9e635ba29db0d464a 100644 (file)
@@ -7,16 +7,12 @@
  */
 package org.opendaylight.controller.cluster.access.concepts;
 
-import static com.google.common.base.Verify.verifyNotNull;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.base.MoreObjects;
 import java.io.DataInput;
 import java.io.DataOutput;
-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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.cds.types.rev191024.ClientGeneration;
 import org.opendaylight.yangtools.concepts.WritableIdentifier;
@@ -28,61 +24,6 @@ import org.opendaylight.yangtools.yang.common.Uint64;
  * of a particular frontend.
  */
 public final class ClientIdentifier implements WritableIdentifier {
-    interface SerialForm extends Externalizable {
-        @NonNull ClientIdentifier identifier();
-
-        void setIdentifier(@NonNull ClientIdentifier identifier);
-
-        @java.io.Serial
-        Object readResolve();
-
-        @Override
-        default void readExternal(final ObjectInput in) throws IOException {
-            setIdentifier(new ClientIdentifier(FrontendIdentifier.readFrom(in), WritableObjects.readLong(in)));
-        }
-
-        @Override
-        default void writeExternal(final ObjectOutput out) throws IOException {
-            final var id = identifier();
-            id.getFrontendId().writeTo(out);
-            WritableObjects.writeLong(out, id.getGeneration());
-        }
-    }
-
-    @Deprecated(since = "7.0.0", forRemoval = true)
-    private static final class Proxy implements SerialForm {
-        @java.io.Serial
-        private static final long serialVersionUID = 1L;
-
-        private ClientIdentifier identifier;
-
-        // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
-        // be able to create instances via reflection.
-        @SuppressWarnings("checkstyle:RedundantModifier")
-        public Proxy() {
-            // Needed for Externalizable
-        }
-
-        Proxy(final ClientIdentifier identifier) {
-            this.identifier = requireNonNull(identifier);
-        }
-
-        @Override
-        public ClientIdentifier identifier() {
-            return verifyNotNull(identifier);
-        }
-
-        @Override
-        public void setIdentifier(final ClientIdentifier identifier) {
-            this.identifier = requireNonNull(identifier);
-        }
-
-        @Override
-        public Object readResolve() {
-            return identifier();
-        }
-    }
-
     @java.io.Serial
     private static final long serialVersionUID = 1L;
 
index e80a38dad93a1afebc47ca0413fdc33d36bab095..3038437fcd664df3fd6bbd11d67817639ea27091 100644 (file)
@@ -10,10 +10,12 @@ package org.opendaylight.controller.cluster.access.concepts;
 import static com.google.common.base.Verify.verifyNotNull;
 import static java.util.Objects.requireNonNull;
 
+import java.io.ObjectInput;
+
 /**
  * Serialization proxy for {@link FailureEnvelope}.
  */
-final class FE implements FailureEnvelope.SerialForm {
+final class FE implements ResponseEnvelope.SerialForm<RequestFailure<?, ?>, FailureEnvelope> {
     @java.io.Serial
     private static final long serialVersionUID = 1L;
 
@@ -38,6 +40,12 @@ final class FE implements FailureEnvelope.SerialForm {
         this.envelope = requireNonNull(envelope);
     }
 
+    @Override
+    public FailureEnvelope readExternal(final ObjectInput in, final long sessionId, final long txSequence,
+            final RequestFailure<?, ?> message, final long executionTimeNanos) {
+        return new FailureEnvelope(message, sessionId, txSequence, executionTimeNanos);
+    }
+
     @Override
     public Object readResolve() {
         return envelope();
index 4640c3fa1336c04465191a6e0f72f5b3662fd0cb..1a3e72b83103ee79d048cf19d13022c7833fb169 100644 (file)
@@ -10,10 +10,15 @@ package org.opendaylight.controller.cluster.access.concepts;
 import static com.google.common.base.Verify.verifyNotNull;
 import static java.util.Objects.requireNonNull;
 
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
 /**
  * Serialization proxy for {@link FrontendIdentifier}.
  */
-final class FI implements FrontendIdentifier.SerialForm {
+final class FI implements Externalizable {
     @java.io.Serial
     private static final long serialVersionUID = 1L;
 
@@ -29,17 +34,18 @@ final class FI implements FrontendIdentifier.SerialForm {
     }
 
     @Override
-    public FrontendIdentifier identifier() {
-        return verifyNotNull(identifier);
+    public void readExternal(final ObjectInput in) throws IOException {
+        identifier = new FrontendIdentifier(MemberName.readFrom(in), FrontendType.readFrom(in));
     }
 
     @Override
-    public void setIdentifier(final FrontendIdentifier identifier) {
-        this.identifier = requireNonNull(identifier);
+    public void writeExternal(final ObjectOutput out) throws IOException {
+        identifier.getMemberName().writeTo(out);
+        identifier.getClientType().writeTo(out);
     }
 
-    @Override
-    public Object readResolve() {
-        return identifier();
+    @java.io.Serial
+    private Object readResolve() {
+        return verifyNotNull(identifier);
     }
 }
index 60c45fefc652e8e1af5b086e14934e7cb3759353..9e900f7e401e0e684f65481e0c137c16e8188518 100644 (file)
@@ -7,39 +7,47 @@
  */
 package org.opendaylight.controller.cluster.access.concepts;
 
-import static com.google.common.base.Verify.verifyNotNull;
 import static java.util.Objects.requireNonNull;
 
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.nio.charset.StandardCharsets;
+
 /**
  * Serialization proxy for {@link FrontendType}.
  */
-final class FT implements FrontendType.SerialForm {
+final class FT implements Externalizable {
     @java.io.Serial
     private static final long serialVersionUID = 1L;
 
-    private FrontendType type;
+    private byte[] serialized;
 
     @SuppressWarnings("checkstyle:RedundantModifier")
     public FT() {
         // for Externalizable
     }
 
-    FT(final FrontendType type) {
-        this.type = requireNonNull(type);
+    FT(final byte[] serialized) {
+        this.serialized = requireNonNull(serialized);
     }
 
     @Override
-    public FrontendType type() {
-        return verifyNotNull(type);
+    public void writeExternal(final ObjectOutput out) throws IOException {
+        out.writeInt(serialized.length);
+        out.write(serialized);
     }
 
     @Override
-    public void setType(final FrontendType type) {
-        this.type = requireNonNull(type);
+    public void readExternal(final ObjectInput in) throws IOException {
+        serialized = new byte[in.readInt()];
+        in.readFully(serialized);
     }
 
-    @Override
-    public Object readResolve() {
-        return type();
+    @java.io.Serial
+    private Object readResolve() {
+        // TODO: consider caching instances here
+        return new FrontendType(new String(serialized, StandardCharsets.UTF_8), serialized);
     }
 }
index 10024a206e9d7ff7d290b7aeb8804b8ce5ca5f05..76aad38da71e4d802b988771b292c7fc34a01dba 100644 (file)
@@ -7,15 +7,11 @@
  */
 package org.opendaylight.controller.cluster.access.concepts;
 
-import static com.google.common.base.Verify.verifyNotNull;
 import static java.util.Objects.requireNonNull;
 
 import java.io.DataInput;
 import java.io.DataOutput;
-import java.io.Externalizable;
 import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
 import java.util.Objects;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.WritableIdentifier;
@@ -24,61 +20,6 @@ import org.opendaylight.yangtools.concepts.WritableIdentifier;
  * A cluster-wide unique identifier of a frontend type located at a cluster member.
  */
 public final class FrontendIdentifier implements WritableIdentifier {
-    interface SerialForm extends Externalizable {
-        @NonNull FrontendIdentifier identifier();
-
-        void setIdentifier(@NonNull FrontendIdentifier identifier);
-
-        @java.io.Serial
-        Object readResolve();
-
-        @Override
-        default void writeExternal(final ObjectOutput out) throws IOException {
-            final var id = identifier();
-            id.memberName.writeTo(out);
-            id.clientType.writeTo(out);
-        }
-
-        @Override
-        default void readExternal(final ObjectInput in) throws IOException {
-            setIdentifier(new FrontendIdentifier(MemberName.readFrom(in), FrontendType.readFrom(in)));
-        }
-    }
-
-    @Deprecated(since = "7.0.0", forRemoval = true)
-    private static final class Proxy implements SerialForm {
-        @java.io.Serial
-        private static final long serialVersionUID = 1L;
-
-        private FrontendIdentifier identifier;
-
-        // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
-        // be able to create instances via reflection.
-        @SuppressWarnings("checkstyle:RedundantModifier")
-        public Proxy() {
-            // Needed for Externalizable
-        }
-
-        Proxy(final FrontendIdentifier identifier) {
-            this.identifier = requireNonNull(identifier);
-        }
-
-        @Override
-        public FrontendIdentifier identifier() {
-            return verifyNotNull(identifier);
-        }
-
-        @Override
-        public void setIdentifier(final FrontendIdentifier identifier) {
-            this.identifier = requireNonNull(identifier);
-        }
-
-        @Override
-        public Object readResolve() {
-            return identifier();
-        }
-    }
-
     @java.io.Serial
     private static final long serialVersionUID = 1L;
 
@@ -95,8 +36,8 @@ public final class FrontendIdentifier implements WritableIdentifier {
     }
 
     public static @NonNull FrontendIdentifier readFrom(final DataInput in) throws IOException {
-        final MemberName memberName = MemberName.readFrom(in);
-        final FrontendType clientType = FrontendType.readFrom(in);
+        final var memberName = MemberName.readFrom(in);
+        final var clientType = FrontendType.readFrom(in);
         return new FrontendIdentifier(memberName, clientType);
     }
 
index 1ccdd69a07481557b4f99b2c1ee83fc51ea57d8a..66191816136573bdce79299a33d388012b163cf3 100644 (file)
@@ -16,10 +16,7 @@ import com.google.common.base.Strings;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.DataInput;
 import java.io.DataOutput;
-import java.io.Externalizable;
 import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
 import java.nio.charset.StandardCharsets;
 import java.util.regex.Pattern;
 import org.eclipse.jdt.annotation.NonNull;
@@ -32,64 +29,6 @@ import org.opendaylight.yangtools.concepts.WritableIdentifier;
  * discerned.
  */
 public final class FrontendType implements Comparable<FrontendType>, WritableIdentifier {
-    interface SerialForm extends Externalizable {
-        @NonNull FrontendType type();
-
-        void setType(@NonNull FrontendType type);
-
-        @java.io.Serial
-        Object readResolve();
-
-        @Override
-        default void writeExternal(final ObjectOutput out) throws IOException {
-            final var serialized = type().getSerialized();
-            out.writeInt(serialized.length);
-            out.write(serialized);
-        }
-
-        @Override
-        default void readExternal(final ObjectInput in) throws IOException {
-            final var serialized = new byte[in.readInt()];
-            in.readFully(serialized);
-            // TODO: consider caching instances here
-            setType(new FrontendType(new String(serialized, StandardCharsets.UTF_8), serialized));
-        }
-    }
-
-    @Deprecated(since = "7.0.0", forRemoval = true)
-    private static final class Proxy implements SerialForm {
-        @java.io.Serial
-        private static final long serialVersionUID = 1L;
-
-        private FrontendType type;
-
-        // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
-        // be able to create instances via reflection.
-        @SuppressWarnings("checkstyle:RedundantModifier")
-        public Proxy() {
-            // For Externalizable
-        }
-
-        Proxy(final FrontendType type) {
-            this.type = requireNonNull(type);
-        }
-
-        @Override
-        public FrontendType type() {
-            return verifyNotNull(type);
-        }
-
-        @Override
-        public void setType(final FrontendType type) {
-            this.type = requireNonNull(type);
-        }
-
-        @Override
-        public Object readResolve() {
-            return type();
-        }
-    }
-
     @java.io.Serial
     private static final long serialVersionUID = 1L;
     private static final String SIMPLE_STRING_REGEX = "^[a-zA-Z0-9-_.*+:=,!~';]+$";
@@ -181,6 +120,6 @@ public final class FrontendType implements Comparable<FrontendType>, WritableIde
 
     @java.io.Serial
     private Object writeReplace() {
-        return new FT(this);
+        return new FT(getSerialized());
     }
 }
index a0d4795ac67d899cb659f1e2ebff158f3fa27fd7..ab4d884eee7a19f3fc9d748613790743cc738ec1 100644 (file)
@@ -10,10 +10,23 @@ package org.opendaylight.controller.cluster.access.concepts;
 import static com.google.common.base.Verify.verifyNotNull;
 import static java.util.Objects.requireNonNull;
 
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.opendaylight.yangtools.concepts.WritableObjects;
+
 /**
  * Serialization proxy for {@link LocalHistoryIdentifier}.
+ *
+ * @implNote
+ *     cookie is currently required only for module-based sharding, which is implemented as part of normal
+ *     DataBroker interfaces. For DOMDataTreeProducer cookie will always be zero, hence we may end up not needing
+ *     cookie at all.
+ *     We use WritableObjects.writeLongs() to output historyId and cookie (in that order). If we end up not needing
+ *     the cookie at all, we can switch to writeLong() and use zero flags for compatibility.
  */
-final class HI implements LocalHistoryIdentifier.SerialForm {
+final class HI implements Externalizable {
     @java.io.Serial
     private static final long serialVersionUID = 1L;
 
@@ -29,17 +42,22 @@ final class HI implements LocalHistoryIdentifier.SerialForm {
     }
 
     @Override
-    public LocalHistoryIdentifier identifier() {
-        return verifyNotNull(identifier);
+    public void writeExternal(final ObjectOutput out) throws IOException {
+        identifier.getClientId().writeTo(out);
+        WritableObjects.writeLongs(out, identifier.getHistoryId(), identifier.getCookie());
     }
 
     @Override
-    public void setIdentifier(final LocalHistoryIdentifier identifier) {
-        this.identifier = requireNonNull(identifier);
+    public void readExternal(final ObjectInput in) throws IOException {
+        final var clientId = ClientIdentifier.readFrom(in);
+        final byte header = WritableObjects.readLongHeader(in);
+        final var historyId = WritableObjects.readFirstLong(in, header);
+        final var cookie = WritableObjects.readSecondLong(in, header);
+        identifier = new LocalHistoryIdentifier(clientId, historyId, cookie);
     }
 
-    @Override
-    public Object readResolve() {
-        return identifier();
+    @java.io.Serial
+    private Object readResolve() {
+        return verifyNotNull(identifier);
     }
 }
index 334f10291d9067a9612b4cfe73b29773588139c7..ddeb2936151b9b8b7f42affa9648a2e53d6a0cb4 100644 (file)
@@ -7,16 +7,12 @@
  */
 package org.opendaylight.controller.cluster.access.concepts;
 
-import static com.google.common.base.Verify.verifyNotNull;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.base.MoreObjects;
 import java.io.DataInput;
 import java.io.DataOutput;
-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.yangtools.concepts.WritableIdentifier;
 import org.opendaylight.yangtools.concepts.WritableObjects;
@@ -28,76 +24,6 @@ import org.opendaylight.yangtools.concepts.WritableObjects;
  * - an unsigned long cookie, assigned by the client and meaningless on the backend, which just reflects it back
  */
 public final class LocalHistoryIdentifier implements WritableIdentifier {
-    /**
-     * Serialized form of {@link LocalHistoryIdentifier}.
-     *
-     * @implNote
-     *     cookie is currently required only for module-based sharding, which is implemented as part of normal
-     *     DataBroker interfaces. For DOMDataTreeProducer cookie will always be zero, hence we may end up not needing
-     *     cookie at all.
-     *     We use WritableObjects.writeLongs() to output historyId and cookie (in that order). If we end up not needing
-     *     the cookie at all, we can switch to writeLong() and use zero flags for compatibility.
-     */
-    interface SerialForm extends Externalizable {
-        @NonNull LocalHistoryIdentifier identifier();
-
-        void setIdentifier(@NonNull LocalHistoryIdentifier identifier);
-
-        @java.io.Serial
-        Object readResolve();
-
-        @Override
-        default void writeExternal(final ObjectOutput out) throws IOException {
-            final var id = identifier();
-            id.getClientId().writeTo(out);
-            WritableObjects.writeLongs(out, id.getHistoryId(), id.getCookie());
-        }
-
-        @Override
-        default void readExternal(final ObjectInput in) throws IOException {
-            final var clientId = ClientIdentifier.readFrom(in);
-
-            final byte header = WritableObjects.readLongHeader(in);
-            final var historyId = WritableObjects.readFirstLong(in, header);
-            final var cookie = WritableObjects.readSecondLong(in, header);
-            setIdentifier(new LocalHistoryIdentifier(clientId, historyId, cookie));
-        }
-    }
-
-    @Deprecated(since = "7.0.0", forRemoval = true)
-    private static final class Proxy implements SerialForm {
-        @java.io.Serial
-        private static final long serialVersionUID = 1L;
-
-        private LocalHistoryIdentifier identifier;
-
-        // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
-        // be able to create instances via reflection.
-        @SuppressWarnings("checkstyle:RedundantModifier")
-        public Proxy() {
-            // For Externalizable
-        }
-
-        Proxy(final LocalHistoryIdentifier identifier) {
-            this.identifier = requireNonNull(identifier);
-        }
-
-        @Override
-        public LocalHistoryIdentifier identifier() {
-            return verifyNotNull(identifier);
-        }
-
-        @Override
-        public void setIdentifier(final LocalHistoryIdentifier identifier) {
-            this.identifier = requireNonNull(identifier);
-        }
-
-        @Override
-        public Object readResolve() {
-            return identifier();
-        }
-    }
-
     @java.io.Serial
     private static final long serialVersionUID = 1L;
 
index 83ef1e59ba0298866046db1c1e26c2dcc79a9600..37b9fb837fda5e906d5fa3fbedf469f2878cd462 100644 (file)
@@ -7,39 +7,47 @@
  */
 package org.opendaylight.controller.cluster.access.concepts;
 
-import static com.google.common.base.Verify.verifyNotNull;
 import static java.util.Objects.requireNonNull;
 
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.nio.charset.StandardCharsets;
+
 /**
  * Serialization proxy for {@link MemberName}.
  */
-final class MN implements MemberName.SerialForm {
+final class MN implements Externalizable {
     @java.io.Serial
     private static final long serialVersionUID = 1L;
 
-    private MemberName name;
+    private byte[] serialized;
 
     @SuppressWarnings("checkstyle:RedundantModifier")
     public MN() {
         // for Externalizable
     }
 
-    MN(final MemberName name) {
-        this.name = requireNonNull(name);
+    MN(final byte[] serialized) {
+        this.serialized = requireNonNull(serialized);
     }
 
     @Override
-    public MemberName name() {
-        return verifyNotNull(name);
+    public void writeExternal(final ObjectOutput out) throws IOException {
+        out.writeInt(serialized.length);
+        out.write(serialized);
     }
 
     @Override
-    public void setName(final MemberName name) {
-        this.name = requireNonNull(name);
+    public void readExternal(final ObjectInput in) throws IOException {
+        serialized = new byte[in.readInt()];
+        in.readFully(serialized);
     }
 
-    @Override
-    public Object readResolve() {
-        return name();
+    @java.io.Serial
+    private Object readResolve() {
+        // TODO: consider caching instances here
+        return new MemberName(new String(serialized, StandardCharsets.UTF_8), serialized);
     }
 }
index 47af6b3b1ebd01395aaeb1fd10e0183d29111398..daab643f8a6e13647d7e92554718a49e70b14570 100644 (file)
@@ -16,10 +16,7 @@ import com.google.common.base.Strings;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.DataInput;
 import java.io.DataOutput;
-import java.io.Externalizable;
 import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
 import java.nio.charset.StandardCharsets;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.WritableIdentifier;
@@ -28,64 +25,6 @@ import org.opendaylight.yangtools.concepts.WritableIdentifier;
  * Type-safe encapsulation of a cluster member name.
  */
 public final class MemberName implements Comparable<MemberName>, WritableIdentifier {
-    interface SerialForm extends Externalizable {
-        @NonNull MemberName name();
-
-        void setName(@NonNull MemberName name);
-
-        @java.io.Serial
-        Object readResolve();
-
-        @Override
-        default void writeExternal(final ObjectOutput out) throws IOException {
-            final var serialized = name().getSerialized();
-            out.writeInt(serialized.length);
-            out.write(serialized);
-        }
-
-        @Override
-        default void readExternal(final ObjectInput in) throws IOException {
-            final var serialized = new byte[in.readInt()];
-            in.readFully(serialized);
-            // TODO: consider caching instances here
-            setName(new MemberName(new String(serialized, StandardCharsets.UTF_8), serialized));
-        }
-    }
-
-    @Deprecated(since = "7.0.0", forRemoval = true)
-    private static final class Proxy implements SerialForm {
-        @java.io.Serial
-        private static final long serialVersionUID = 1L;
-
-        private MemberName name;
-
-        // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
-        // be able to create instances via reflection.
-        @SuppressWarnings("checkstyle:RedundantModifier")
-        public Proxy() {
-            // For Externalizable
-        }
-
-        Proxy(final MemberName name) {
-            this.name = requireNonNull(name);
-        }
-
-        @Override
-        public MemberName name() {
-            return verifyNotNull(name);
-        }
-
-        @Override
-        public void setName(final MemberName name) {
-            this.name = requireNonNull(name);
-        }
-
-        @Override
-        public Object readResolve() {
-            return name();
-        }
-    }
-
     @java.io.Serial
     private static final long serialVersionUID = 1L;
 
@@ -164,6 +103,6 @@ public final class MemberName implements Comparable<MemberName>, WritableIdentif
 
     @java.io.Serial
     Object writeReplace() {
-        return new MN(this);
+        return new MN(getSerialized());
     }
 }
index 653f4fce45b152ced5f92813ad600d201abd095e..8bc927fdbb684240054486bbc98bf60d91fadf56 100644 (file)
@@ -10,10 +10,16 @@ package org.opendaylight.controller.cluster.access.concepts;
 import static com.google.common.base.Verify.verifyNotNull;
 import static java.util.Objects.requireNonNull;
 
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.opendaylight.yangtools.concepts.WritableObjects;
+
 /**
  * Serialization proxy for {@link TransactionIdentifier}.
  */
-final class TI implements TransactionIdentifier.SerialForm {
+final class TI implements Externalizable {
     @java.io.Serial
     private static final long serialVersionUID = 1L;
 
@@ -29,17 +35,18 @@ final class TI implements TransactionIdentifier.SerialForm {
     }
 
     @Override
-    public TransactionIdentifier identifier() {
-        return verifyNotNull(identifier);
+    public void readExternal(final ObjectInput in) throws IOException {
+        identifier = new TransactionIdentifier(LocalHistoryIdentifier.readFrom(in), WritableObjects.readLong(in));
     }
 
     @Override
-    public void setIdentifier(final TransactionIdentifier identifier) {
-        this.identifier = requireNonNull(identifier);
+    public void writeExternal(final ObjectOutput out) throws IOException {
+        identifier.getHistoryId().writeTo(out);
+        WritableObjects.writeLong(out, identifier.getTransactionId());
     }
 
-    @Override
-    public Object readResolve() {
-        return identifier();
+    @java.io.Serial
+    private Object readResolve() {
+        return verifyNotNull(identifier);
     }
 }
index b5c652333ffec1fc842ae36a3a008cb915c192a0..ea72c847501a79a8982af88b1fd6aadfc90784c4 100644 (file)
@@ -7,15 +7,11 @@
  */
 package org.opendaylight.controller.cluster.access.concepts;
 
-import static com.google.common.base.Verify.verifyNotNull;
 import static java.util.Objects.requireNonNull;
 
 import java.io.DataInput;
 import java.io.DataOutput;
-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.yangtools.concepts.WritableIdentifier;
 import org.opendaylight.yangtools.concepts.WritableObjects;
@@ -24,61 +20,6 @@ import org.opendaylight.yangtools.concepts.WritableObjects;
  * Globally-unique identifier of a transaction.
  */
 public final class TransactionIdentifier implements WritableIdentifier {
-    interface SerialForm extends Externalizable {
-        @NonNull TransactionIdentifier identifier();
-
-        void setIdentifier(@NonNull TransactionIdentifier identifier);
-
-        @java.io.Serial
-        Object readResolve();
-
-        @Override
-        default void readExternal(final ObjectInput in) throws IOException {
-            setIdentifier(new TransactionIdentifier(LocalHistoryIdentifier.readFrom(in), WritableObjects.readLong(in)));
-        }
-
-        @Override
-        default void writeExternal(final ObjectOutput out) throws IOException {
-            final var id = identifier();
-            id.getHistoryId().writeTo(out);
-            WritableObjects.writeLong(out, id.getTransactionId());
-        }
-    }
-
-    @Deprecated(since = "7.0.0", forRemoval = true)
-    private static final class Proxy implements SerialForm {
-        @java.io.Serial
-        private static final long serialVersionUID = 1L;
-
-        private TransactionIdentifier identifier;
-
-        // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
-        // be able to create instances via reflection.
-        @SuppressWarnings("checkstyle:RedundantModifier")
-        public Proxy() {
-            // For Externalizable
-        }
-
-        Proxy(final TransactionIdentifier identifier) {
-            this.identifier = requireNonNull(identifier);
-        }
-
-        @Override
-        public @NonNull TransactionIdentifier identifier() {
-            return verifyNotNull(identifier);
-        }
-
-        @Override
-        public void setIdentifier(final TransactionIdentifier identifier) {
-            this.identifier = requireNonNull(identifier);
-        }
-
-        @Override
-        public Object readResolve() {
-            return identifier();
-        }
-    }
-
     @java.io.Serial
     private static final long serialVersionUID = 1L;