Skip to content

Commit

Permalink
Use a singleton JsonClaimSet.Empty (#2195)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub authored and Brent Schmaltz committed Sep 6, 2023
1 parent e718231 commit 6a10950
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ namespace Microsoft.IdentityModel.JsonWebTokens
/// </summary>
internal class JsonClaimSet
{
internal static JsonClaimSet Empty { get; } = new JsonClaimSet("{}"u8.ToArray());

private IList<Claim> _claims;
private readonly object _claimsLock = new object();

Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.IdentityModel.JsonWebTokens/JsonWebToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ private void ReadToken(string encodedJson)
// JWE: https://www.rfc-editor.org/rfc/rfc7516
// Format: https://www.rfc-editor.org/rfc/rfc7516#page-8
// empty payload for JWE's {encrypted tokens}.
Payload = new JsonClaimSet(JsonDocument.Parse("{}"));
Payload = JsonClaimSet.Empty;

if (Dot3 == encodedJson.Length)
throw LogHelper.LogExceptionMessage(new ArgumentException(LogMessages.IDX14121));
Expand Down

0 comments on commit 6a10950

Please sign in to comment.