Deprecate NoopAutoCloseable for removal
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / base / messages / TimeoutNow.java
index 5a753c24c99efe224b752299cfcdfc25168915f7..b212250dd4984828d3c57f8a70f0a177da5cff5c 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.cluster.raft.base.messages;
 
+import akka.dispatch.ControlMessage;
 import java.io.Serializable;
 
 /**
@@ -14,7 +15,7 @@ import java.io.Serializable;
  *
  * @author Thomas Pantelis
  */
-public final class TimeoutNow implements Serializable {
+public final class TimeoutNow implements Serializable, ControlMessage {
     private static final long serialVersionUID = 1L;
     public static final TimeoutNow INSTANCE = new TimeoutNow();
 
@@ -22,7 +23,18 @@ public final class TimeoutNow implements Serializable {
         // Hidden on purpose
     }
 
-    private Object 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);
+        }
     }
 }