Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@

namespace Umbraco.Cms.DevelopmentMode.Backoffice.InMemoryAuto;

internal sealed class InMemoryAssemblyLoadContextManager
internal sealed class InMemoryAssemblyLoadContextManager : IDisposable
{
private UmbracoAssemblyLoadContext? _currentAssemblyLoadContext;

public InMemoryAssemblyLoadContextManager() =>
AssemblyLoadContext.Default.Resolving += OnResolvingDefaultAssemblyLoadContext;

public void Dispose() =>
AssemblyLoadContext.Default.Resolving -= OnResolvingDefaultAssemblyLoadContext;

private string? _modelsAssemblyLocation;

public string? ModelsAssemblyLocation => _modelsAssemblyLocation;
Expand Down
4 changes: 2 additions & 2 deletions src/Umbraco.Infrastructure/Security/MemberPasswordHasher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ private bool IsSuccessfulLegacyPassword(string hashedPassword, string providedPa
private static string DecryptLegacyPassword(string encryptedPassword, SymmetricAlgorithm algorithm)
{
using var memoryStream = new MemoryStream();
ICryptoTransform cryptoTransform = algorithm.CreateDecryptor();
var cryptoStream = new CryptoStream(memoryStream, cryptoTransform, CryptoStreamMode.Write);
using ICryptoTransform cryptoTransform = algorithm.CreateDecryptor();
using var cryptoStream = new CryptoStream(memoryStream, cryptoTransform, CryptoStreamMode.Write);
var buf = Convert.FromBase64String(encryptedPassword);
cryptoStream.Write(buf, 0, 32);
cryptoStream.FlushFinalBlock();
Expand Down
12 changes: 11 additions & 1 deletion src/Umbraco.Infrastructure/Services/CacheInstructionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,17 @@ private int ProcessDatabaseInstructions(CacheRefresherCollection cacheRefreshers
continue;
}

List<RefreshInstruction> instructionBatch = GetAllInstructions(jsonInstructions?.RootElement);
// Dispose the JsonDocument once we've extracted instructions from its RootElement.
// Use try/finally to ensure pooled buffers are returned even if retrieving the instructions throws.
List<RefreshInstruction> instructionBatch;
try
{
instructionBatch = GetAllInstructions(jsonInstructions?.RootElement);
}
finally
{
jsonInstructions?.Dispose();
}

// Process as per-normal.
var success = ProcessDatabaseInstructions(cacheRefreshers, instructionBatch, instruction, processed, cancellationToken, ref lastId);
Expand Down
1 change: 1 addition & 0 deletions src/Umbraco.Infrastructure/Sync/DatabaseServerMessenger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ protected virtual void Dispose(bool disposing)
if (disposing)
{
_syncIdle.Dispose();
_cancellationTokenSource.Dispose();
}

_disposedValue = true;
Expand Down
Loading