Skip to content

Commit d17a866

Browse files
committed
Fix caching bug when retrieving artifact
This commit fixes a caching bug when retrieving an artifact. The ToString() value of Product should be used rather than just ProductName, as the ToString() value will also take into account the SubProductName, if there's a SubProduct set.
1 parent 94ca414 commit d17a866

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Elastic.Stack.Artifacts/ElasticVersion.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ protected ElasticVersion(string version, ArtifactBuildState state, string buildH
2121
private readonly ConcurrentDictionary<string, Artifact> _resolved = new ConcurrentDictionary<string, Artifact>();
2222
public Artifact Artifact(Product product)
2323
{
24-
Artifact artifact;
25-
if (_resolved.TryGetValue(product.ProductName, out artifact))
24+
var cacheKey = product.ToString();
25+
if (_resolved.TryGetValue(cacheKey, out var artifact))
2626
return artifact;
2727
switch (ArtifactBuildState)
2828
{
@@ -39,7 +39,7 @@ public Artifact Artifact(Product product)
3939
throw new ArgumentOutOfRangeException(nameof(ArtifactBuildState), $"{ArtifactBuildState} not expected here");
4040
}
4141

42-
_resolved.TryAdd(product.ProductName, artifact);
42+
_resolved.TryAdd(cacheKey, artifact);
4343

4444
return artifact;
4545
}

0 commit comments

Comments
 (0)