Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit c17a62b

Browse files
committed
Add additional logging and skip processing invalid response
1 parent c77219f commit c17a62b

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

src/ServiceStack.Redis/RedisNativeClient.cs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,7 +1544,7 @@ public List<Dictionary<string, string>> SentinelMasters()
15441544
Commands.Masters,
15451545
};
15461546
var results = SendExpectDeeplyNestedMultiData(args.ToArray());
1547-
return (from object[] result in results select ToDictionary(result)).ToList();
1547+
return ToDictionaryList(results);
15481548
}
15491549

15501550
public Dictionary<string, string> SentinelMaster(string masterName)
@@ -1568,7 +1568,7 @@ public List<Dictionary<string, string>> SentinelSentinels(string masterName)
15681568
masterName.ToUtf8Bytes(),
15691569
};
15701570
var results = SendExpectDeeplyNestedMultiData(args.ToArray());
1571-
return (from object[] result in results select ToDictionary(result)).ToList();
1571+
return ToDictionaryList(results);
15721572
}
15731573

15741574
public List<Dictionary<string, string>> SentinelSlaves(string masterName)
@@ -1580,7 +1580,32 @@ public List<Dictionary<string, string>> SentinelSlaves(string masterName)
15801580
masterName.ToUtf8Bytes(),
15811581
};
15821582
var results = SendExpectDeeplyNestedMultiData(args.ToArray());
1583-
return (from object[] result in results select ToDictionary(result)).ToList();
1583+
return ToDictionaryList(results);
1584+
}
1585+
1586+
private static List<Dictionary<string, string>> ToDictionaryList(object[] results)
1587+
{
1588+
var to = new List<Dictionary<string, string>>();
1589+
foreach (object result in results)
1590+
{
1591+
var obArray = result as object[];
1592+
if (obArray == null)
1593+
{
1594+
var value = result.ToString();
1595+
var bytes = result as byte[];
1596+
if (bytes != null)
1597+
value = bytes.FromUtf8Bytes();
1598+
1599+
log.ErrorFormat("Expected object[] received {0}: {1}",
1600+
result.GetType().Name, value);
1601+
1602+
continue;
1603+
}
1604+
1605+
var item = ToDictionary(obArray);
1606+
to.Add(item);
1607+
}
1608+
return to;
15841609
}
15851610

15861611
public List<string> SentinelGetMasterAddrByName(string masterName)

0 commit comments

Comments
 (0)