Skip to content

Commit

Permalink
Avoid throwing exception when receiving invalid SqlNotificationInfo v…
Browse files Browse the repository at this point in the history
…alue (#1378)
  • Loading branch information
Johnny Pham authored Nov 17, 2021
1 parent d853ac4 commit 397279b
Showing 1 changed file with 18 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1131,37 +1131,25 @@ internal static SqlNotification ProcessMessage(SqlXml xmlMessage)
messageAttributes |= MessageAttributes.Source;
break;
case InfoAttribute:
try
{
string value = xmlReader.Value;
// 3 of the server info values do not match client values - map.
switch (value)
{
case "set options":
info = SqlNotificationInfo.Options;
break;
case "previous invalid":
info = SqlNotificationInfo.PreviousFire;
break;
case "query template limit":
info = SqlNotificationInfo.TemplateLimit;
break;
default:
SqlNotificationInfo temp = (SqlNotificationInfo)Enum.Parse(typeof(SqlNotificationInfo), value, true);
if (Enum.IsDefined(typeof(SqlNotificationInfo), temp))
{
info = temp;
}
break;
}
}
catch (Exception e)
string value = xmlReader.Value;
// 3 of the server info values do not match client values - map.
switch (value)
{
if (!ADP.IsCatchableExceptionType(e))
{
throw;
}
ADP.TraceExceptionWithoutRethrow(e); // Discard failure, if it should occur.
case "set options":
info = SqlNotificationInfo.Options;
break;
case "previous invalid":
info = SqlNotificationInfo.PreviousFire;
break;
case "query template limit":
info = SqlNotificationInfo.TemplateLimit;
break;
default:
if (Enum.TryParse(value, true, out SqlNotificationInfo temp) && Enum.IsDefined(typeof(SqlNotificationInfo), temp))
{
info = temp;
}
break;
}
messageAttributes |= MessageAttributes.Info;
break;
Expand Down

0 comments on commit 397279b

Please sign in to comment.