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.
This commit is contained in:
parent
2cf6ed9460
commit
b24a749ae8
@ -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<ByteBuf> {
|
||||
}
|
||||
|
||||
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<ByteBuf> {
|
||||
}
|
||||
|
||||
public ProtobufDecoder(MessageLite prototype, ExtensionRegistry extensionRegistry) {
|
||||
this(prototype, (ExtensionRegistryLite) extensionRegistry);
|
||||
}
|
||||
|
||||
public ProtobufDecoder(MessageLite prototype, ExtensionRegistryLite extensionRegistry) {
|
||||
if (prototype == null) {
|
||||
throw new NullPointerException("prototype");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user