Skip to content

Commit c509aa3

Browse files
[Api] Fix regression test
Fix-up the regression test so it actually detects the issue caused by #5749.
1 parent 5842eec commit c509aa3

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

test/OpenTelemetry.Tests/Trace/Propagation/TraceContextPropagatorTests.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,19 @@ public void TryExtractTracestate_SingleHeaderRejectsDuplicateLongKeys()
244244
}
245245

246246
[Fact]
247-
public void Extract_AllowsKeyNamesInsideEarlierValues()
247+
public async Task Extract_DoesNotHangWhenLaterKeyAppearsInsideEarlierValue()
248248
{
249-
// Regression test for GHSA-8785-wc3w-h8q6.
250-
Assert.Equal("foo=bar,bar=1", CallTraceContextPropagator("foo=bar,bar=1"));
251-
Assert.Equal("foo=bar,bar=1", CallTraceContextPropagator(["foo=bar", "bar=1"]));
249+
// Regression test for GHSA-8785-wc3w-h8q6
250+
const string tracestate = "foo1=foo2,foo2=1";
251+
252+
var deadline = TimeSpan.FromSeconds(1);
253+
254+
var extractionTask = Task.Run(() => CallTraceContextPropagator(tracestate));
255+
var completedTask = await Task.WhenAny(extractionTask, Task.Delay(deadline));
256+
257+
Assert.True(extractionTask.IsCompleted, $"The task did not complete within {deadline}.");
258+
Assert.Same(extractionTask, completedTask);
259+
Assert.Equal(tracestate, await extractionTask);
252260
}
253261

254262
[Fact]

0 commit comments

Comments
 (0)