fix file not closed (#571)

This commit is contained in:
Boshi Lian
2021-02-24 21:35:24 -08:00
committed by GitHub
parent a5614df8bc
commit b282b9571b

View File

@@ -56,6 +56,8 @@ namespace k8s
/// <summary> /// <summary>
/// Load a collection of objects from a stream asynchronously /// Load a collection of objects from a stream asynchronously
///
/// caller is responsible for closing the stream
/// </summary> /// </summary>
/// <param name="stream"> /// <param name="stream">
/// The stream to load the objects from. /// The stream to load the objects from.
@@ -80,8 +82,10 @@ namespace k8s
/// <returns>collection of objects</returns> /// <returns>collection of objects</returns>
public static Task<List<object>> LoadAllFromFileAsync(string fileName, Dictionary<string, Type> typeMap) public static Task<List<object>> LoadAllFromFileAsync(string fileName, Dictionary<string, Type> typeMap)
{ {
var reader = File.OpenRead(fileName); using (var reader = File.OpenRead(fileName))
return LoadAllFromStreamAsync(reader, typeMap); {
return LoadAllFromStreamAsync(reader, typeMap);
}
} }
/// <summary> /// <summary>