From b24a749ae879a61ebd871cab541ffe6ac7d29b5a Mon Sep 17 00:00:00 2001 From: "Barber, Francis" Date: Thu, 28 Aug 2014 21:24:38 -0700 Subject: [PATCH] Add support for ExtensionRegistryLite in ProtobufDecoder Motivation: ExtensionRegistry is a subclass of ExtensionRegistryLite. The ProtobufDecoder doesn't use the registry directly, it simply passes it through to the Protobuf API. The Protobuf calls in question are themselves written in terms ExtensionRegistryLite not ExtensionRegistry. Modifications: Require ExtensionRegistryLite instead of ExtensionRegistry in ProtobufDecoder. Result: Consumers can use ExtensionRegistryLite with ProtobufDecoder. --- .../io/netty/handler/codec/protobuf/ProtobufDecoder.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/codec/src/main/java/io/netty/handler/codec/protobuf/ProtobufDecoder.java b/codec/src/main/java/io/netty/handler/codec/protobuf/ProtobufDecoder.java index ee91191bb4..a31e16461e 100644 --- a/codec/src/main/java/io/netty/handler/codec/protobuf/ProtobufDecoder.java +++ b/codec/src/main/java/io/netty/handler/codec/protobuf/ProtobufDecoder.java @@ -16,6 +16,7 @@ package io.netty.handler.codec.protobuf; import com.google.protobuf.ExtensionRegistry; +import com.google.protobuf.ExtensionRegistryLite; import com.google.protobuf.Message; import com.google.protobuf.MessageLite; import io.netty.buffer.ByteBuf; @@ -78,7 +79,7 @@ public class ProtobufDecoder extends MessageToMessageDecoder { } private final MessageLite prototype; - private final ExtensionRegistry extensionRegistry; + private final ExtensionRegistryLite extensionRegistry; /** * Creates a new instance. @@ -88,6 +89,10 @@ public class ProtobufDecoder extends MessageToMessageDecoder { } public ProtobufDecoder(MessageLite prototype, ExtensionRegistry extensionRegistry) { + this(prototype, (ExtensionRegistryLite) extensionRegistry); + } + + public ProtobufDecoder(MessageLite prototype, ExtensionRegistryLite extensionRegistry) { if (prototype == null) { throw new NullPointerException("prototype"); }