Skip to content

Commit

Permalink
feat: always reset stream position after call to serializer (#235)
Browse files Browse the repository at this point in the history
* feat: always reset stream position after call to serializer

* docs: remove setting stream position from custom serializer sample
  • Loading branch information
daveleek authored Aug 13, 2024
1 parent a153aea commit 9263f72
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,6 @@ public class NewtonsoftJson7Serializer : IJsonSerializer
Serializer.Serialize(jsonWriter, instance);

jsonWriter.Flush();
stream.Position = 0;
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/Unleash/Communication/UnleashApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ public async Task<bool> RegisterClient(ClientRegistration registration, Cancella

var memoryStream = new MemoryStream();
jsonSerializer.Serialize(memoryStream, registration);
memoryStream.Position = 0;

const int bufferSize = 1024 * 4;

Expand Down Expand Up @@ -233,6 +234,7 @@ public async Task<bool> SendMetrics(ThreadSafeMetricsBucket metrics, Cancellatio
InstanceId = clientRequestHeaders.InstanceTag,
Bucket = bucket
});
memoryStream.Position = 0;
}

const int bufferSize = 1024 * 4;
Expand Down

0 comments on commit 9263f72

Please sign in to comment.