From 558097449cb9719f0ebd5332b954d06fe8280e86 Mon Sep 17 00:00:00 2001 From: Idel Pivnitskiy Date: Sat, 14 Oct 2017 07:16:04 -0700 Subject: [PATCH] Add missed 'serialVersionUID' field for Serializable classes Motivation: Without a 'serialVersionUID' field, any change to a class will make previously serialized versions unreadable. Modifications: Add missed 'serialVersionUID' field for all Serializable classes. Result: Proper deserialization of previously serialized objects. --- .../java/io/netty/handler/codec/http2/Http2Exception.java | 2 ++ .../io/netty/handler/codec/http2/Http2StreamChannelId.java | 1 + .../codec/serialization/CompatibleObjectEncoderTest.java | 2 ++ common/src/main/java/io/netty/util/ResourceLeakDetector.java | 1 + handler/src/main/java/io/netty/handler/ssl/PemPrivateKey.java | 1 + .../src/test/java/io/netty/handler/ssl/JdkSslEngineTest.java | 2 ++ handler/src/test/java/io/netty/handler/ssl/SslErrorTest.java | 1 + handler/src/test/java/io/netty/handler/ssl/ocsp/OcspTest.java | 2 ++ .../java/io/netty/resolver/dns/DnsNameResolverContext.java | 2 ++ .../netty/channel/socket/ChannelOutputShutdownException.java | 2 ++ .../src/test/java/io/netty/channel/PendingWriteQueueTest.java | 4 +++- 11 files changed, 19 insertions(+), 1 deletion(-) diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2Exception.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2Exception.java index 7d309d791b..258f871eb8 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2Exception.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2Exception.java @@ -252,6 +252,8 @@ public class Http2Exception extends Exception { } public static final class HeaderListSizeException extends StreamException { + private static final long serialVersionUID = -8807603212183882637L; + private final boolean decode; HeaderListSizeException(int streamId, Http2Error error, String message, boolean decode) { diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2StreamChannelId.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2StreamChannelId.java index 5cb32255e0..a25c4202ec 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2StreamChannelId.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2StreamChannelId.java @@ -21,6 +21,7 @@ import io.netty.channel.ChannelId; * ChannelId implementation which is used by our {@link Http2StreamChannel} implementation. */ final class Http2StreamChannelId implements ChannelId { + private static final long serialVersionUID = -6642338822166867585L; private final int id; private final ChannelId parentId; diff --git a/codec/src/test/java/io/netty/handler/codec/serialization/CompatibleObjectEncoderTest.java b/codec/src/test/java/io/netty/handler/codec/serialization/CompatibleObjectEncoderTest.java index 629a323acb..238b91e342 100644 --- a/codec/src/test/java/io/netty/handler/codec/serialization/CompatibleObjectEncoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/serialization/CompatibleObjectEncoderTest.java @@ -53,6 +53,8 @@ public class CompatibleObjectEncoderTest { } private static final class TestSerializable implements Serializable { + private static final long serialVersionUID = 2235771472534930360L; + public final int x; public final int y; diff --git a/common/src/main/java/io/netty/util/ResourceLeakDetector.java b/common/src/main/java/io/netty/util/ResourceLeakDetector.java index 33b878cf79..ea6f69a951 100644 --- a/common/src/main/java/io/netty/util/ResourceLeakDetector.java +++ b/common/src/main/java/io/netty/util/ResourceLeakDetector.java @@ -539,6 +539,7 @@ public class ResourceLeakDetector { } private static final class Record extends Throwable { + private static final long serialVersionUID = 6065153674892850720L; private static final Record BOTTOM = new Record(); diff --git a/handler/src/main/java/io/netty/handler/ssl/PemPrivateKey.java b/handler/src/main/java/io/netty/handler/ssl/PemPrivateKey.java index c1b828c027..e7bfd12392 100644 --- a/handler/src/main/java/io/netty/handler/ssl/PemPrivateKey.java +++ b/handler/src/main/java/io/netty/handler/ssl/PemPrivateKey.java @@ -41,6 +41,7 @@ import io.netty.util.internal.ObjectUtil; * @see #valueOf(ByteBuf) */ public final class PemPrivateKey extends AbstractReferenceCounted implements PrivateKey, PemEncoded { + private static final long serialVersionUID = 7978017465645018936L; private static final byte[] BEGIN_PRIVATE_KEY = "-----BEGIN PRIVATE KEY-----\n".getBytes(CharsetUtil.US_ASCII); private static final byte[] END_PRIVATE_KEY = "\n-----END PRIVATE KEY-----\n".getBytes(CharsetUtil.US_ASCII); diff --git a/handler/src/test/java/io/netty/handler/ssl/JdkSslEngineTest.java b/handler/src/test/java/io/netty/handler/ssl/JdkSslEngineTest.java index 110871b360..f37a6aff25 100644 --- a/handler/src/test/java/io/netty/handler/ssl/JdkSslEngineTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/JdkSslEngineTest.java @@ -352,6 +352,8 @@ public class JdkSslEngineTest extends SSLEngineTest { } private static final class SkipTestException extends RuntimeException { + private static final long serialVersionUID = 9214869217774035223L; + SkipTestException(String message) { super(message); } diff --git a/handler/src/test/java/io/netty/handler/ssl/SslErrorTest.java b/handler/src/test/java/io/netty/handler/ssl/SslErrorTest.java index aacdb6978d..27aa9bfe16 100644 --- a/handler/src/test/java/io/netty/handler/ssl/SslErrorTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/SslErrorTest.java @@ -247,6 +247,7 @@ public class SslErrorTest { } private static final class TestCertificateException extends CertificateException { + private static final long serialVersionUID = -5816338303868751410L; public TestCertificateException(Throwable cause) { super(cause); diff --git a/handler/src/test/java/io/netty/handler/ssl/ocsp/OcspTest.java b/handler/src/test/java/io/netty/handler/ssl/ocsp/OcspTest.java index 4aecc74800..313ceb0afa 100644 --- a/handler/src/test/java/io/netty/handler/ssl/ocsp/OcspTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/ocsp/OcspTest.java @@ -494,6 +494,8 @@ public class OcspTest { } private static final class OcspTestException extends IllegalStateException { + private static final long serialVersionUID = 4516426833250228159L; + public OcspTestException(String message) { super(message); } diff --git a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolverContext.java b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolverContext.java index 5f023aeffd..848b321cf4 100644 --- a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolverContext.java +++ b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolverContext.java @@ -153,6 +153,8 @@ abstract class DnsNameResolverContext { } private static final class SearchDomainUnknownHostException extends UnknownHostException { + private static final long serialVersionUID = -8573510133644997085L; + SearchDomainUnknownHostException(Throwable cause, String originalHostname) { super("Search domain query failed. Original hostname: '" + originalHostname + "' " + cause.getMessage()); setStackTrace(cause.getStackTrace()); diff --git a/transport/src/main/java/io/netty/channel/socket/ChannelOutputShutdownException.java b/transport/src/main/java/io/netty/channel/socket/ChannelOutputShutdownException.java index 500a5aab48..75393a02ae 100644 --- a/transport/src/main/java/io/netty/channel/socket/ChannelOutputShutdownException.java +++ b/transport/src/main/java/io/netty/channel/socket/ChannelOutputShutdownException.java @@ -26,6 +26,8 @@ import java.io.IOException; */ @UnstableApi public final class ChannelOutputShutdownException extends IOException { + private static final long serialVersionUID = 6712549938359321378L; + public ChannelOutputShutdownException(String msg) { super(msg); } diff --git a/transport/src/test/java/io/netty/channel/PendingWriteQueueTest.java b/transport/src/test/java/io/netty/channel/PendingWriteQueueTest.java index 88c5e794f2..f2770281ea 100644 --- a/transport/src/test/java/io/netty/channel/PendingWriteQueueTest.java +++ b/transport/src/test/java/io/netty/channel/PendingWriteQueueTest.java @@ -377,5 +377,7 @@ public class PendingWriteQueueTest { } } - private static final class TestException extends Exception { } + private static final class TestException extends Exception { + private static final long serialVersionUID = -9018570103039458401L; + } }