Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .autover/changes/81dcfb46-b496-46d0-9a50-1318e39541f6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"Projects": [
{
"Name": "AWS.Messaging",
"Type": "Minor",
"ChangelogMessages": [
"Implement Utf8JsonWriter based serializer"
]
}
]
}
7 changes: 7 additions & 0 deletions AWS.Messaging.sln
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PollyIntegration", "samplea
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppHost", "sampleapps\AppHost\AppHost.csproj", "{C028BF43-16C6-42FB-B422-5AD4F15B492C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AWS.Messaging.Benchmarks.Serialization", "test\AWS.Messaging.Benchmarks.Serialization\AWS.Messaging.Benchmarks.Serialization.csproj", "{393E7D65-0D04-A989-A4BC-85E36A16530E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -99,6 +101,10 @@ Global
{C028BF43-16C6-42FB-B422-5AD4F15B492C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C028BF43-16C6-42FB-B422-5AD4F15B492C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C028BF43-16C6-42FB-B422-5AD4F15B492C}.Release|Any CPU.Build.0 = Release|Any CPU
{393E7D65-0D04-A989-A4BC-85E36A16530E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{393E7D65-0D04-A989-A4BC-85E36A16530E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{393E7D65-0D04-A989-A4BC-85E36A16530E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{393E7D65-0D04-A989-A4BC-85E36A16530E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -117,6 +123,7 @@ Global
{143DC3E0-A1C6-4670-86F4-E7CD4C8F52CB} = {80DB2C77-6ADD-4A60-B27D-763BDF9659D3}
{86896246-B032-4D34-82BE-CD5ACB6E43F9} = {1AA8985B-897C-4BD5-9735-FD8B33FEBFFB}
{C028BF43-16C6-42FB-B422-5AD4F15B492C} = {1AA8985B-897C-4BD5-9735-FD8B33FEBFFB}
{393E7D65-0D04-A989-A4BC-85E36A16530E} = {80DB2C77-6ADD-4A60-B27D-763BDF9659D3}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7B2B759D-6455-4089-8173-3F1619567B36}
Expand Down
23 changes: 21 additions & 2 deletions src/AWS.Messaging/Configuration/MessageBusBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class MessageBusBuilder : IMessageBusBuilder
private readonly IList<ServiceDescriptor> _additionalServices = new List<ServiceDescriptor>();
private readonly IServiceCollection _serviceCollection;

private bool _experimentalFeaturesEnabled;

/// <summary>
/// Creates an instance of <see cref="MessageBusBuilder"/>.
/// </summary>
Expand Down Expand Up @@ -321,6 +323,12 @@ public IMessageBusBuilder ConfigureBackoffPolicy(Action<BackoffPolicyBuilder> co
return this;
}

public IMessageBusBuilder EnableExperimentalFeatures()
{
_experimentalFeaturesEnabled = true;
return this;
}

internal void Build()
{
LoadConfigurationFromEnvironment();
Expand All @@ -332,8 +340,19 @@ internal void Build()

_serviceCollection.TryAddSingleton(_messageConfiguration.PollingControlToken);
_serviceCollection.TryAddSingleton<IMessageConfiguration>(_messageConfiguration);
_serviceCollection.TryAddSingleton<IMessageSerializer, MessageSerializer>();
_serviceCollection.TryAddSingleton<IEnvelopeSerializer, EnvelopeSerializer>();

if (_experimentalFeaturesEnabled)
{
_serviceCollection.AddSingleton<IEnvelopeSerializer, EnvelopeSerializerUtf8JsonWriter>();
_serviceCollection.TryAddSingleton<IMessageSerializer, MessageSerializerUtf8JsonWriter>();

}
else
{
_serviceCollection.AddSingleton<IEnvelopeSerializer, EnvelopeSerializer>();
_serviceCollection.TryAddSingleton<IMessageSerializer, MessageSerializer>();
}

_serviceCollection.TryAddSingleton<IDateTimeHandler, DateTimeHandler>();
_serviceCollection.TryAddSingleton<IMessageIdGenerator, MessageIdGenerator>();
_serviceCollection.TryAddSingleton<IAWSClientProvider, AWSClientProvider>();
Expand Down
8 changes: 8 additions & 0 deletions src/AWS.Messaging/Configuration/SerializerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ public class SerializationOptions
Converters = { new JsonStringEnumConverter() }
};

/// <summary>
/// When set to true, it will clean the rented buffers after each use.
/// </summary>
/// <remarks>
/// Setting this to false can improve performance in high-throughput scenarios at cost of potential security issues
Copy link

Copilot AI Aug 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation should be more explicit about the security risks. Consider adding details about what type of sensitive data could be exposed and under what conditions, to help users make informed decisions about this trade-off.

Suggested change
/// Setting this to false can improve performance in high-throughput scenarios at cost of potential security issues
/// Setting this to false can improve performance in high-throughput scenarios, but introduces security risks.
/// If buffers are not cleaned after use, sensitive data such as user credentials, personal information, authentication tokens,
/// or cryptographic keys may remain in memory. This residual data could potentially be accessed by other code or processes
/// that reuse the same buffers, leading to unintended data exposure. Consider the sensitivity of the data being processed
/// and the threat model of your application before disabling buffer cleaning.

Copilot uses AI. Check for mistakes.

/// </remarks>
public bool CleanRentedBuffers { get; set; } = true;

/// <summary>
/// Default constructor
/// </summary>
Expand Down
Loading