Skip to content

Commit ab32485

Browse files
committed
Fix async stream disposal in DeserializeOrThrowAsync
Non-async method with using var stream returned ValueTask without await, causing stream to be disposed before deserialization completed (ObjectDisposedException on SafeFileHandle).
1 parent 2102085 commit ab32485

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Configuration/Paths.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ public static async ValueTask<T> DeserializeAsync<T>(this string filePath, IFile
807807
/// <param name="fileSystem">File system.</param>
808808
/// <param name="cancellationToken"><see cref="CancellationToken"/></param>
809809
/// <returns>Value.</returns>
810-
public static ValueTask<T> DeserializeOrThrowAsync<T>(this string filePath, IFileSystem fileSystem, CancellationToken cancellationToken)
810+
public static async ValueTask<T> DeserializeOrThrowAsync<T>(this string filePath, IFileSystem fileSystem, CancellationToken cancellationToken)
811811
{
812812
if (filePath.IsEmpty())
813813
throw new ArgumentNullException(nameof(filePath));
@@ -821,7 +821,7 @@ public static ValueTask<T> DeserializeOrThrowAsync<T>(this string filePath, IFil
821821
throw new FileNotFoundException($"file not found: '{defFile}'");
822822

823823
using var stream = fileSystem.OpenRead(defFile);
824-
return CreateSerializer<T>().DeserializeAsync(stream, cancellationToken);
824+
return await CreateSerializer<T>().DeserializeAsync(stream, cancellationToken);
825825
}
826826

827827
/// <summary>

0 commit comments

Comments
 (0)