@@ -279,8 +279,8 @@ private void DeliveryReportCallbackImpl(IntPtr rk, IntPtr rkmessage, IntPtr opaq
279
279
280
280
private void ProduceImpl (
281
281
string topic ,
282
- ReadOnlyMemory < byte > val ,
283
- ReadOnlyMemory < byte > key ,
282
+ ReadOnlyMemory < byte > ? val ,
283
+ ReadOnlyMemory < byte > ? key ,
284
284
Timestamp timestamp ,
285
285
Partition partition ,
286
286
IReadOnlyList < IHeader > headers ,
@@ -765,7 +765,7 @@ public async Task<DeliveryResult<TKey, TValue>> ProduceAsync(
765
765
{
766
766
Headers headers = message . Headers ?? new Headers ( ) ;
767
767
768
- ReadOnlyMemory < byte > keyBytes ;
768
+ ReadOnlyMemory < byte > ? keyBytes ;
769
769
try
770
770
{
771
771
if ( message . Key is Memory < byte > memory )
@@ -778,9 +778,10 @@ public async Task<DeliveryResult<TKey, TValue>> ProduceAsync(
778
778
}
779
779
else
780
780
{
781
- keyBytes = ( keySerializer != null )
781
+ byte [ ] keyBytesArray = keySerializer != null
782
782
? keySerializer . Serialize ( message . Key , new SerializationContext ( MessageComponentType . Key , topicPartition . Topic , headers ) )
783
783
: await asyncKeySerializer . SerializeAsync ( message . Key , new SerializationContext ( MessageComponentType . Key , topicPartition . Topic , headers ) ) . ConfigureAwait ( false ) ;
784
+ keyBytes = keyBytesArray == null ? ( ReadOnlyMemory < byte > ? ) null : keyBytesArray ;
784
785
}
785
786
}
786
787
catch ( Exception ex )
@@ -795,7 +796,7 @@ public async Task<DeliveryResult<TKey, TValue>> ProduceAsync(
795
796
ex ) ;
796
797
}
797
798
798
- ReadOnlyMemory < byte > valBytes ;
799
+ ReadOnlyMemory < byte > ? valBytes ;
799
800
try
800
801
{
801
802
if ( message . Value is Memory < byte > memory )
@@ -808,9 +809,10 @@ public async Task<DeliveryResult<TKey, TValue>> ProduceAsync(
808
809
}
809
810
else
810
811
{
811
- valBytes = ( valueSerializer != null )
812
+ byte [ ] valBytesArray = valueSerializer != null
812
813
? valueSerializer . Serialize ( message . Value , new SerializationContext ( MessageComponentType . Value , topicPartition . Topic , headers ) )
813
814
: await asyncValueSerializer . SerializeAsync ( message . Value , new SerializationContext ( MessageComponentType . Value , topicPartition . Topic , headers ) ) . ConfigureAwait ( false ) ;
815
+ valBytes = valBytesArray == null ? ( ReadOnlyMemory < byte > ? ) null : valBytesArray ;
814
816
}
815
817
}
816
818
catch ( Exception ex )
@@ -910,7 +912,7 @@ public void Produce(
910
912
911
913
Headers headers = message . Headers ?? new Headers ( ) ;
912
914
913
- ReadOnlyMemory < byte > keyBytes ;
915
+ ReadOnlyMemory < byte > ? keyBytes ;
914
916
try
915
917
{
916
918
if ( message . Key is Memory < byte > memory )
@@ -923,9 +925,10 @@ public void Produce(
923
925
}
924
926
else
925
927
{
926
- keyBytes = ( keySerializer != null )
928
+ byte [ ] keyBytesArray = keySerializer != null
927
929
? keySerializer . Serialize ( message . Key , new SerializationContext ( MessageComponentType . Key , topicPartition . Topic , headers ) )
928
930
: throw new InvalidOperationException ( "Produce called with an IAsyncSerializer key serializer configured but an ISerializer is required." ) ;
931
+ keyBytes = keyBytesArray == null ? ( ReadOnlyMemory < byte > ? ) null : keyBytesArray ;
929
932
}
930
933
}
931
934
catch ( Exception ex )
@@ -940,7 +943,7 @@ public void Produce(
940
943
ex ) ;
941
944
}
942
945
943
- ReadOnlyMemory < byte > valBytes ;
946
+ ReadOnlyMemory < byte > ? valBytes ;
944
947
try
945
948
{
946
949
if ( message . Value is Memory < byte > memory )
@@ -953,9 +956,10 @@ public void Produce(
953
956
}
954
957
else
955
958
{
956
- valBytes = ( valueSerializer != null )
959
+ byte [ ] valBytesArray = valueSerializer != null
957
960
? valueSerializer . Serialize ( message . Value , new SerializationContext ( MessageComponentType . Value , topicPartition . Topic , headers ) )
958
961
: throw new InvalidOperationException ( "Produce called with an IAsyncSerializer value serializer configured but an ISerializer is required." ) ;
962
+ valBytes = valBytesArray == null ? ( ReadOnlyMemory < byte > ? ) null : valBytesArray ;
959
963
}
960
964
}
961
965
catch ( Exception ex )
0 commit comments