From f36ca373206340a25b1d3bb226acc7b679128a7c Mon Sep 17 00:00:00 2001 From: Richard Webb Date: Mon, 13 Apr 2020 14:19:12 +0100 Subject: [PATCH] Merge PR #432: Throw ArgumentNullException in BZip2 Change the BZip2 Compress/Decompress functions to throw ArgumentNullxception rather than Exception when null stream parameters are provided --- src/ICSharpCode.SharpZipLib/BZip2/BZip2.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/ICSharpCode.SharpZipLib/BZip2/BZip2.cs b/src/ICSharpCode.SharpZipLib/BZip2/BZip2.cs index ec6ff9402..4bd48b035 100644 --- a/src/ICSharpCode.SharpZipLib/BZip2/BZip2.cs +++ b/src/ICSharpCode.SharpZipLib/BZip2/BZip2.cs @@ -17,10 +17,11 @@ public static class BZip2 /// Both streams are closed on completion if true. public static void Decompress(Stream inStream, Stream outStream, bool isStreamOwner) { - if (inStream == null || outStream == null) - { - throw new Exception("Null Stream"); - } + if (inStream == null) + throw new ArgumentNullException(nameof(inStream)); + + if (outStream == null) + throw new ArgumentNullException(nameof(outStream)); try { @@ -51,10 +52,11 @@ public static void Decompress(Stream inStream, Stream outStream, bool isStreamOw /// the lowest compression and 9 the highest. public static void Compress(Stream inStream, Stream outStream, bool isStreamOwner, int level) { - if (inStream == null || outStream == null) - { - throw new Exception("Null Stream"); - } + if (inStream == null) + throw new ArgumentNullException(nameof(inStream)); + + if (outStream == null) + throw new ArgumentNullException(nameof(outStream)); try {