Skip to content

Commit 135a401

Browse files
Havretrayokota
andauthored
Refactor serializer implementations to remove unnecessary ContinueWith calls (#2448)
Co-authored-by: Robert Yokota <[email protected]>
1 parent e31a0aa commit 135a401

File tree

4 files changed

+5
-8
lines changed

4 files changed

+5
-8
lines changed

src/Confluent.SchemaRegistry.Serdes.Avro/GenericSerializerImpl.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,8 @@ public async Task<byte[]> Serialize(string topic, Headers headers, GenericRecord
165165
{
166166
return await AvroUtils.Transform(ctx, writerSchema, message, transform).ConfigureAwait(false);
167167
};
168-
data = await ExecuteRules(isKey, subject, topic, headers, RuleMode.Write, null,
168+
data = (GenericRecord) await ExecuteRules(isKey, subject, topic, headers, RuleMode.Write, null,
169169
latestSchema, data, fieldTransformer)
170-
.ContinueWith(t => (GenericRecord)t.Result)
171170
.ConfigureAwait(continueOnCapturedContext: false);
172171
}
173172

src/Confluent.SchemaRegistry.Serdes.Avro/SpecificSerializerImpl.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,8 @@ public async Task<byte[]> Serialize(string topic, Headers headers, T data, bool
206206
{
207207
return await AvroUtils.Transform(ctx, schema, message, transform).ConfigureAwait(false);
208208
};
209-
data = await ExecuteRules(isKey, subject, topic, headers, RuleMode.Write, null,
209+
data = (T) await ExecuteRules(isKey, subject, topic, headers, RuleMode.Write, null,
210210
latestSchema, data, fieldTransformer)
211-
.ContinueWith(t => (T) t.Result)
212211
.ConfigureAwait(continueOnCapturedContext: false);
213212
}
214213

src/Confluent.SchemaRegistry.Serdes.Json/JsonSerializer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,9 @@ public override async Task<byte[]> SerializeAsync(T value, SerializationContext
242242
{
243243
return await JsonUtils.Transform(ctx, parsedSchema, "$", message, transform).ConfigureAwait(false);
244244
};
245-
value = await ExecuteRules(context.Component == MessageComponentType.Key, subject,
245+
value = (T) await ExecuteRules(context.Component == MessageComponentType.Key, subject,
246246
context.Topic, context.Headers, RuleMode.Write, null,
247247
latestSchema, value, fieldTransformer)
248-
.ContinueWith(t => (T)t.Result)
249248
.ConfigureAwait(continueOnCapturedContext: false);
250249
}
251250
else

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,10 @@ await RegisterOrGetReferences(value.Descriptor.File, context, autoRegisterSchema
301301
{
302302
return await ProtobufUtils.Transform(ctx, fdSet, message, transform).ConfigureAwait(false);
303303
};
304-
value = await ExecuteRules(context.Component == MessageComponentType.Key, subject,
304+
value = (T) await ExecuteRules(context.Component == MessageComponentType.Key, subject,
305305
context.Topic, context.Headers, RuleMode.Write, null,
306306
latestSchema, value, fieldTransformer)
307-
.ContinueWith(t => (T)t.Result).ConfigureAwait(continueOnCapturedContext: false);
307+
.ConfigureAwait(continueOnCapturedContext: false);
308308
}
309309

310310
using (var stream = new MemoryStream(initialBufferSize))

0 commit comments

Comments
 (0)