Skip to content

Commit

Permalink
Deal with concurrency in a better way
Browse files Browse the repository at this point in the history
  • Loading branch information
dtillman authored and Tim Hess committed Dec 12, 2019
1 parent 94c2e6e commit 1f1279a
Showing 1 changed file with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,16 +264,16 @@ internal ConfigEnvironment DoLoad(bool updateDictionary = true)
"Located environment: {name}, {profiles}, {label}, {version}, {state}", env.Name, env.Profiles, env.Label, env.Version, env.State);
if (updateDictionary)
{
Data.Clear();
IDictionary<string, string> newData = new Dictionary<string, string>();

if (!string.IsNullOrEmpty(env.State))
{
Data["spring:cloud:config:client:state"] = env.State;
newData["spring:cloud:config:client:state"] = env.State;
}

if (!string.IsNullOrEmpty(env.Version))
{
Data["spring:cloud:config:client:version"] = env.Version;
newData["spring:cloud:config:client:version"] = env.Version;
}

var sources = env.PropertySources;
Expand All @@ -282,9 +282,11 @@ internal ConfigEnvironment DoLoad(bool updateDictionary = true)
int index = sources.Count - 1;
for (; index >= 0; index--)
{
AddPropertySource(sources[index]);
AddPropertySource(sources[index], newData);
}
}

Data = newData;
}

return env;
Expand Down Expand Up @@ -661,7 +663,18 @@ protected internal virtual string GetConfigServerUri(string label)
/// by this provider
/// </summary>
/// <param name="source">a property source to add</param>
[Obsolete("Will be removed in next release.")]
protected internal virtual void AddPropertySource(PropertySource source)
{
AddPropertySource(source, Data);
}

/// <summary>
/// Adds values from a PropertySource to the provided dictionary.
/// </summary>
/// <param name="source">a property source to add</param>
/// <param name="data">the dictionary to add the property source to</param>
protected internal void AddPropertySource(PropertySource source, IDictionary<string, string> data)
{
if (source == null || source.Source == null)
{
Expand All @@ -674,7 +687,7 @@ protected internal virtual void AddPropertySource(PropertySource source)
{
string key = ConvertKey(kvp.Key);
string value = ConvertValue(kvp.Value);
Data[key] = value;
data[key] = value;
}
catch (Exception e)
{
Expand Down

0 comments on commit 1f1279a

Please sign in to comment.