Fix ObjectDisposedException thrown when calling Yaml.LoadAllFromFileAsync (#573)

This commit is contained in:
Alex Meyer-Gleaves
2021-02-27 17:21:43 +10:00
committed by GitHub
parent b282b9571b
commit a4350d6c8f
2 changed files with 68 additions and 3 deletions

View File

@@ -80,11 +80,11 @@ namespace k8s
/// <param name="fileName">The name of the file to load from.</param>
/// <param name="typeMap">A map from apiVersion/kind to Type. For example "v1/Pod" -> typeof(V1Pod)</param>
/// <returns>collection of objects</returns>
public static Task<List<object>> LoadAllFromFileAsync(string fileName, Dictionary<string, Type> typeMap)
public static async Task<List<object>> LoadAllFromFileAsync(string fileName, Dictionary<string, Type> typeMap)
{
using (var reader = File.OpenRead(fileName))
using (var fileStream = File.OpenRead(fileName))
{
return LoadAllFromStreamAsync(reader, typeMap);
return await LoadAllFromStreamAsync(fileStream, typeMap).ConfigureAwait(false);
}
}