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

Commit

Permalink
Avoid potential race condition
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
haacked committed Aug 5, 2015
1 parent fc55a67 commit c5ac231
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/GitHub.Api/SimpleApiClientFactory.cs
@@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using GitHub.Models;
using GitHub.Primitives;
using GitHub.Services;
using Octokit;
using System.Collections.Generic;

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

public ISimpleApiClient Create(UriString repositoryUrl)
{
var contains = cache.ContainsKey(repositoryUrl);
if (contains)
return cache[repositoryUrl];

lock (cache)
{
if (!cache.ContainsKey(repositoryUrl))
Expand Down

0 comments on commit c5ac231

Please sign in to comment.