Skip to content

Commit a892b7e

Browse files
yinzararayokota
andauthored
Allow null SchemaRegistryClient in AsyncSerde constructor (#2267) (#2304)
Co-authored-by: Robert Yokota <[email protected]>
1 parent 30011fe commit a892b7e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Confluent.SchemaRegistry/AsyncSerde.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ protected AsyncSerde(ISchemaRegistryClient schemaRegistryClient, SerdeConfig con
5151

5252
if (config == null) { return; }
5353

54-
IEnumerable<KeyValuePair<string, string>> ruleConfigs = schemaRegistryClient.Config.Concat(config
54+
IEnumerable<KeyValuePair<string, string>> ruleConfigs = config
5555
.Select(kv => new KeyValuePair<string, string>(
56-
kv.Key.StartsWith("rules.") ? kv.Key.Substring("rules.".Length) : kv.Key, kv.Value)));
56+
kv.Key.StartsWith("rules.") ? kv.Key.Substring("rules.".Length) : kv.Key, kv.Value));
57+
if (schemaRegistryClient != null)
58+
ruleConfigs = schemaRegistryClient.Config.Concat(ruleConfigs);
5759

5860
foreach (IRuleExecutor executor in this.ruleExecutors.Concat(RuleRegistry.GetRuleExecutors()))
5961
{

test/Confluent.SchemaRegistry.Serdes.UnitTests/ProtoSerializeDeserialize.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,5 +393,12 @@ message PersonWithPic {
393393
Assert.True(pic.SequenceEqual(result.Picture));
394394
}
395395

396+
[Fact]
397+
public void ProtobufDeserializerWithoutSchemaRegistry()
398+
{
399+
new ProtobufDeserializer<Person>();
400+
Assert.True(true); // if constructor does not throw exception we're ok
401+
}
402+
396403
}
397404
}

0 commit comments

Comments
 (0)