Skip to content

Commit b7f6202

Browse files
committed
fix last-minute ARGREP result change
1 parent d9a7b52 commit b7f6202

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/StackExchange.Redis/ResultProcessor.Arrays.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes
7575

7676
private sealed class RedisArrayEntryArrayProcessor : ValuePairInterleavedProcessorBase<RedisArrayEntry>
7777
{
78+
protected override bool AllowJaggedPairs(in RawResult result) => true; // i.e. even in RESP2
79+
7880
protected override RedisArrayEntry Parse(in RawResult first, in RawResult second, object? state)
7981
{
8082
TryParseArrayIndex(first, out RedisArrayIndex index);

src/StackExchange.Redis/ResultProcessor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ internal abstract class ValuePairInterleavedProcessorBase<T> : ResultProcessor<T
699699
// happened, and we need to handle that; thus, by default, we'll detect jagged data
700700
// and handle it automatically; this virtual is included so we can turn it off
701701
// on a per-processor basis if needed
702-
protected virtual bool AllowJaggedPairs => true;
702+
protected virtual bool AllowJaggedPairs(in RawResult result) => result.IsResp3;
703703

704704
public bool TryParse(in RawResult result, out T[]? pairs)
705705
=> TryParse(result, out pairs, false, out _);
@@ -719,7 +719,7 @@ public bool TryParse(in RawResult result, out T[]? pairs)
719719
return [];
720720
}
721721

722-
bool interleaved = !(result.IsResp3 && AllowJaggedPairs && IsAllJaggedPairs(arr));
722+
bool interleaved = !(AllowJaggedPairs(result) && IsAllJaggedPairs(arr));
723723
if (interleaved) count >>= 1; // so: half of that
724724
var pairs = allowOversized ? ArrayPool<T>.Shared.Rent(count) : new T[count];
725725

@@ -2287,7 +2287,7 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes
22872287

22882288
private sealed class RedisStreamInterleavedProcessor : ValuePairInterleavedProcessorBase<RedisStream>
22892289
{
2290-
protected override bool AllowJaggedPairs => false; // we only use this on a flattened map
2290+
protected override bool AllowJaggedPairs(in RawResult result) => false; // we only use this on a flattened map
22912291

22922292
public static readonly RedisStreamInterleavedProcessor Instance = new();
22932293
private RedisStreamInterleavedProcessor()

0 commit comments

Comments
 (0)