Skip to content

Commit 922a41b

Browse files
authored
Raise an error if Protobuf deprecated format is specified (#2479)
* Raise an error if Protobuf deprecated format is specified * Minor cleanup
1 parent 7b4ba94 commit 922a41b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/Confluent.SchemaRegistry.Serdes.Protobuf/ProtobufDeserializer.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ namespace Confluent.SchemaRegistry.Serdes
4747
/// </remarks>
4848
public class ProtobufDeserializer<T> : AsyncDeserializer<T, FileDescriptorSet> where T : class, IMessage<T>, new()
4949
{
50-
private bool useDeprecatedFormat;
51-
5250
private MessageParser<T> parser;
5351

5452
/// <summary>
@@ -82,9 +80,9 @@ public ProtobufDeserializer(ISchemaRegistryClient schemaRegistryClient, Protobuf
8280
}
8381

8482
ProtobufDeserializerConfig protobufConfig = new ProtobufDeserializerConfig(config);
85-
if (protobufConfig.UseDeprecatedFormat != null)
83+
if (protobufConfig.UseDeprecatedFormat != null && protobufConfig.UseDeprecatedFormat.Value)
8684
{
87-
this.useDeprecatedFormat = protobufConfig.UseDeprecatedFormat.Value;
85+
throw new NotSupportedException("ProtobufDeserializer: UseDeprecatedFormat is no longer supported");
8886
}
8987

9088
if (config.UseLatestVersion != null) { this.useLatestVersion = config.UseLatestVersion.Value; }

src/Confluent.SchemaRegistry.Serdes.Protobuf/ProtobufSerializer.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ namespace Confluent.SchemaRegistry.Serdes
5353
public class ProtobufSerializer<T> : AsyncSerializer<T, FileDescriptorSet> where T : IMessage<T>, new()
5454
{
5555
private bool skipKnownTypes = true;
56-
private bool useDeprecatedFormat;
5756
private ReferenceSubjectNameStrategyDelegate referenceSubjectNameStrategy;
5857

5958
/// <remarks>
@@ -91,7 +90,10 @@ public ProtobufSerializer(ISchemaRegistryClient schemaRegistryClient, ProtobufSe
9190
if (config.UseLatestVersion != null) { this.useLatestVersion = config.UseLatestVersion.Value; }
9291
if (config.UseLatestWithMetadata != null) { this.useLatestWithMetadata = config.UseLatestWithMetadata; }
9392
if (config.SkipKnownTypes != null) { this.skipKnownTypes = config.SkipKnownTypes.Value; }
94-
if (config.UseDeprecatedFormat != null) { this.useDeprecatedFormat = config.UseDeprecatedFormat.Value; }
93+
if (config.UseDeprecatedFormat != null && config.UseDeprecatedFormat.Value)
94+
{
95+
throw new NotSupportedException("ProtobufSerializer: UseDeprecatedFormat is no longer supported");
96+
}
9597
if (config.SubjectNameStrategy != null) { this.subjectNameStrategy = config.SubjectNameStrategy.Value.ToDelegate(); }
9698
if (config.SchemaIdStrategy != null) { this.schemaIdEncoder = config.SchemaIdStrategy.Value.ToEncoder(); }
9799
this.referenceSubjectNameStrategy = config.ReferenceSubjectNameStrategy == null

0 commit comments

Comments
 (0)