Bug 5740: Change TimeoutNow and Shutdown to externalizable proxy
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / client / messages / Shutdown.java
index 5b76685cb731c5cf9e3b9145d0585d5e67184efb..22acc41e01e9dfee46042a008c813ff1f1cc561d 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.controller.cluster.raft.client.messages;
 
 import java.io.Serializable;
+import org.opendaylight.controller.cluster.raft.base.messages.EmptyExternalizableProxy;
 
 /**
  * Message sent to a raft actor to shutdown gracefully. If it's the leader it will transfer leadership to a
@@ -24,8 +25,18 @@ public final class Shutdown implements Serializable {
         // Hidden on purpose
     }
 
-    @SuppressWarnings({ "static-method", "unused" })
-    private Shutdown readResolve() {
-        return INSTANCE;
+    private Object writeReplace() {
+        return new Proxy();
+    }
+
+    private static class Proxy extends EmptyExternalizableProxy {
+        private static final long serialVersionUID = 1L;
+
+        // 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() {
+            super(INSTANCE);
+        }
     }
 }