Skip to content

Commit 889a54c

Browse files
paulirwinclaude
andcommitted
Address Copilot review on #1090 MMapDirectory.Map fix
Narrow the ArgumentOutOfRangeException retry filter to ParamName == "capacity" so unrelated argument errors aren't masked, and mark the regression test NonParallelizable since it relies on static counters on MMapDirectory. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d1126fb commit 889a54c

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

src/Lucene.Net.Tests/Store/TestMultiMMap.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,10 @@ private void AssertChunking(Random random, int chunkSize)
425425
// stat, causing ArgumentOutOfRangeException (paramName="capacity")
426426
// with the message "The capacity may not be smaller than the
427427
// file size."
428-
[Test, LuceneNetSpecific, Slow]
428+
// NonParallelizable: the retry-path assertion reads static counters on
429+
// MMapDirectory, so any other test exercising MMapDirectory in parallel
430+
// could skew the observed retry count.
431+
[Test, LuceneNetSpecific, Slow, NonParallelizable]
429432
public void TestOpenInputConcurrentFileExtension_Issue1090()
430433
{
431434
var dir = CreateTempDir("testOpenInputConcurrentFileExtension");

src/Lucene.Net/Store/MMapDirectory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ internal virtual ByteBuffer[] Map(MMapIndexInput input, FileStream fc, long offs
350350
leaveOpen: true); // LUCENENET: We explicitly dispose the FileStream separately.
351351
break;
352352
}
353-
catch (ArgumentOutOfRangeException) when (attempt < maxAttempts - 1)
353+
catch (ArgumentOutOfRangeException e) when (e.ParamName == "capacity" && attempt < maxAttempts - 1)
354354
{
355355
Interlocked.Increment(ref s_capacityRetryCount);
356356
capacity = Math.Max(capacity, fc.Length);

0 commit comments

Comments
 (0)