Skip to content

Commit 65eaf21

Browse files
committed
PR feedback: don't rethrow exception if null; range checks
1 parent 3961cb5 commit 65eaf21

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/Lucene.Net/Store/MMapDirectory.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,14 @@ private static void DisposeResourcesWhileHandlingException(Exception? priorExcep
633633
.Concat([mmf, fs]);
634634

635635
// DisposeWhileHandlingException tolerates null disposables
636-
IOUtils.DisposeWhileHandlingException(priorException, disposables);
636+
if (priorException is null)
637+
{
638+
IOUtils.DisposeWhileHandlingException(disposables);
639+
}
640+
else
641+
{
642+
IOUtils.DisposeWhileHandlingException(priorException, disposables);
643+
}
637644
}
638645
}
639646

src/Lucene.Net/Support/Store/UnsafeChunkIndexInput.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ protected void EnsureOpen()
187187

188188
public override void Seek(long pos)
189189
{
190-
if ((uint)pos > (uint)length)
190+
if ((uint)pos >= (uint)length)
191191
{
192192
throw new ArgumentOutOfRangeException(nameof(pos), $"Seek position is out of bounds: {pos}");
193193
}
@@ -436,7 +436,7 @@ public override void SkipBytes(long numBytes)
436436
throw new ArgumentOutOfRangeException(nameof(numBytes), "numBytes must not be negative");
437437
}
438438
long newPos = position + numBytes;
439-
if ((ulong)newPos > (ulong)length)
439+
if ((ulong)newPos >= (ulong)length)
440440
{
441441
throw EOFException.Create("skip past EOF: " + this);
442442
}

0 commit comments

Comments
 (0)