Skip to content

Commit

Permalink
SWEEP: Reviewed all catch blocks where Lucene uses EOFException and c…
Browse files Browse the repository at this point in the history
…onverted them to use our IsEOFException() extension method (see apache#446).
  • Loading branch information
NightOwl888 committed Apr 14, 2021
1 parent 3f202f4 commit cc4a313
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ protected override void Dispose(bool disposing)
// {
// x = @in.ReadInt32();
// }
// catch (EndOfStreamException)
// catch (Exception e) when (e.IsEOFException())
// {
// changed = true;
// break;
Expand Down
8 changes: 2 additions & 6 deletions src/Lucene.Net/Util/OfflineSorter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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];
Expand Down

0 comments on commit cc4a313

Please sign in to comment.