Skip to content

Commit

Permalink
Fix implementation of CloseWhileHandlingException
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirwin committed Dec 5, 2024
1 parent 36235e0 commit c95a56a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/Lucene.Net.TestFramework/Analysis/MockTokenizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,13 @@ public override void Close()
// in some exceptional cases (e.g. TestIndexWriterExceptions) a test can prematurely close()
// these tests should disable this check, by default we check the normal workflow.
// TODO: investigate the CachingTokenFilter "double-close"... for now we ignore this
if (Debugging.AssertsEnabled) Debugging.Assert(!enableChecks || streamState == State.END || streamState == State.CLOSE,"Dispose() called in wrong state: {0}", streamState);
if (Debugging.AssertsEnabled) Debugging.Assert(!enableChecks || streamState == State.END || streamState == State.CLOSE, "Close() called in wrong state: {0}", streamState);
streamState = State.CLOSE;
}

internal override bool SetReaderTestPoint()
{
if (Debugging.AssertsEnabled) Debugging.Assert(!enableChecks || streamState == State.CLOSE,"SetReader() called in wrong state: {0}", streamState);
if (Debugging.AssertsEnabled) Debugging.Assert(!enableChecks || streamState == State.CLOSE, "SetReader() called in wrong state: {0}", streamState);
streamState = State.SETREADER;
return true;
}
Expand Down
18 changes: 0 additions & 18 deletions src/Lucene.Net/Util/IOUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,6 @@ public static void CloseWhileHandlingException(Exception priorException, IEnumer
/// <param name="objects">Objects to call <see cref="ICloseable.Close()"/> on</param>
public static void CloseWhileHandlingException(params ICloseable[] objects)
{
Exception th = null;

foreach (ICloseable @object in objects)
{
try
Expand All @@ -222,15 +220,8 @@ public static void CloseWhileHandlingException(params ICloseable[] objects)
}
catch (Exception t) when (t.IsThrowable())
{
AddSuppressed(th, t);
if (th is null)
{
th = t;
}
}
}

ReThrow(th);
}

/// <summary>
Expand All @@ -240,8 +231,6 @@ public static void CloseWhileHandlingException(params ICloseable[] objects)
/// <seealso cref="CloseWhileHandlingException(ICloseable[])"/>
public static void CloseWhileHandlingException(IEnumerable<ICloseable> objects)
{
Exception th = null;

foreach (ICloseable @object in objects)
{
try
Expand All @@ -250,15 +239,8 @@ public static void CloseWhileHandlingException(IEnumerable<ICloseable> objects)
}
catch (Exception t) when (t.IsThrowable())
{
AddSuppressed(th, t);
if (th is null)
{
th = t;
}
}
}

ReThrow(th);
}


Expand Down

0 comments on commit c95a56a

Please sign in to comment.