Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit c5ac231

Browse files
committed
Avoid potential race condition
In theory, if "ClearFormCache" is called after we check `contains` but before we execute the `return` line, we could get an exception here. If we're concerned about performance here, we could consider switching to the ConcurrentDictionary.
1 parent fc55a67 commit c5ac231

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/GitHub.Api/SimpleApiClientFactory.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.ComponentModel.Composition;
34
using GitHub.Models;
45
using GitHub.Primitives;
56
using GitHub.Services;
67
using Octokit;
7-
using System.Collections.Generic;
88

99
namespace GitHub.Api
1010
{
@@ -28,10 +28,6 @@ public SimpleApiClientFactory(IProgram program, Lazy<IEnterpriseProbeTask> enter
2828

2929
public ISimpleApiClient Create(UriString repositoryUrl)
3030
{
31-
var contains = cache.ContainsKey(repositoryUrl);
32-
if (contains)
33-
return cache[repositoryUrl];
34-
3531
lock (cache)
3632
{
3733
if (!cache.ContainsKey(repositoryUrl))

0 commit comments

Comments
 (0)