diff --git a/src/Lucene.Net.Tests.TestFramework/Store/TestMockDirectoryWrapper.cs b/src/Lucene.Net.Tests.TestFramework/Store/TestMockDirectoryWrapper.cs index c893daedc5..a31ca4f425 100644 --- a/src/Lucene.Net.Tests.TestFramework/Store/TestMockDirectoryWrapper.cs +++ b/src/Lucene.Net.Tests.TestFramework/Store/TestMockDirectoryWrapper.cs @@ -248,7 +248,7 @@ protected override void Dispose(bool disposing) // { // x = @in.ReadInt32(); // } - // catch (EndOfStreamException) + // catch (Exception e) when (e.IsEOFException()) // { // changed = true; // break; diff --git a/src/Lucene.Net/Util/OfflineSorter.cs b/src/Lucene.Net/Util/OfflineSorter.cs index 2e810ce127..490bc624a8 100644 --- a/src/Lucene.Net/Util/OfflineSorter.cs +++ b/src/Lucene.Net/Util/OfflineSorter.cs @@ -622,12 +622,10 @@ public virtual bool Read(BytesRef @ref) { length = (ushort)inputStream.ReadInt16(); } -#pragma warning disable CA1031 // Do not catch general exception types - catch (EndOfStreamException) + catch (Exception e) when (e.IsEOFException()) { return false; } -#pragma warning restore CA1031 // Do not catch general exception types @ref.Grow(length); @ref.Offset = 0; @@ -650,12 +648,10 @@ public virtual byte[] Read() { length = (ushort)inputStream.ReadInt16(); } -#pragma warning disable CA1031 // Do not catch general exception types - catch (EndOfStreamException) + catch (Exception e) when (e.IsEOFException()) { return null; } -#pragma warning restore CA1031 // Do not catch general exception types if (Debugging.AssertsEnabled) Debugging.Assert(length >= 0, "Sanity: sequence length < 0: {0}", length); byte[] result = new byte[length];