Skip to content

Commit b1258b1

Browse files
paulirwinclaude
andcommitted
Route the base DataInput VInt throws through the VIntUtils helpers too, #1279
For consistency with the concrete-reader overrides, the base ReadVInt32/64 slow path now calls the non-inlined VIntUtils.ThrowInvalidVInt32/64() helpers rather than throwing inline. Addresses PR #1345 review feedback. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 7588d15 commit b1258b1

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/Lucene.Net/Store/DataInput.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using J2N.Numerics;
22
using J2N.Text;
33
using Lucene.Net.Diagnostics;
4+
using Lucene.Net.Support;
45
using Lucene.Net.Support.Buffers;
56
using Lucene.Net.Util;
67
using System;
@@ -198,7 +199,8 @@ public virtual int ReadVInt32()
198199
{
199200
return i;
200201
}
201-
throw new IOException("Invalid VInt32 detected (too many bits)");
202+
VIntUtils.ThrowInvalidVInt32();
203+
return 0; // unreachable; ThrowInvalidVInt32 always throws
202204
}
203205

204206
/// <summary>
@@ -295,7 +297,8 @@ public virtual long ReadVInt64()
295297
{
296298
return i;
297299
}
298-
throw new IOException("Invalid VInt64 detected (negative values disallowed)");
300+
VIntUtils.ThrowInvalidVInt64();
301+
return 0; // unreachable; ThrowInvalidVInt64 always throws
299302
}
300303

301304
#nullable enable

src/Lucene.Net/Support/VIntUtils.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ public static bool TryReadVInt64(ReadOnlySpan<byte> source, out long value, out
191191

192192
/// <summary>
193193
/// Throws an <see cref="IOException"/> indicating a malformed 32-bit VInt. Used by the
194-
/// buffered/stream-backed readers, which surface decode failures as I/O errors.
194+
/// base <see cref="Lucene.Net.Store.DataInput"/> and the buffered/stream-backed readers,
195+
/// which surface decode failures as I/O errors.
195196
/// </summary>
196197
[MethodImpl(MethodImplOptions.NoInlining)]
197198
[DoesNotReturn]
@@ -200,7 +201,8 @@ public static void ThrowInvalidVInt32()
200201

201202
/// <summary>
202203
/// Throws an <see cref="IOException"/> indicating a malformed 64-bit VInt. Used by the
203-
/// buffered/stream-backed readers, which surface decode failures as I/O errors.
204+
/// base <see cref="Lucene.Net.Store.DataInput"/> and the buffered/stream-backed readers,
205+
/// which surface decode failures as I/O errors.
204206
/// </summary>
205207
[MethodImpl(MethodImplOptions.NoInlining)]
206208
[DoesNotReturn]

0 commit comments

Comments
 (0)