From a75c7ab1bbb78c372a59c1155ad8657e6ec395d5 Mon Sep 17 00:00:00 2001 From: Eunbin Son Date: Thu, 30 Jul 2026 14:57:18 +0900 Subject: [PATCH] Rename double-remove TraceState tests and exercise a non-first entry Follow-up to review comments on #8613, which were submitted after that PR had already been merged. Rename removeTwice, removeTwice_KeepsRemainingEntry and removeTwice_KeepsRemainingEntries to removeSameKeyTwice*, since all three remove the same key and the previous names did not say so. removeSameKeyTwice_KeepsRemainingEntries now removes SECOND_KEY rather than FIRST_KEY. ArrayBasedTraceStateBuilder.remove scans entries from the front, so removing the first key always matches on the first iteration; removing a middle key covers a later slot for the first time. Test-only: no production code, public API or asserted behavior changes. --- .../io/opentelemetry/api/trace/TraceStateTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/api/all/src/test/java/io/opentelemetry/api/trace/TraceStateTest.java b/api/all/src/test/java/io/opentelemetry/api/trace/TraceStateTest.java index ac95563f5fb..c7634c99e11 100644 --- a/api/all/src/test/java/io/opentelemetry/api/trace/TraceStateTest.java +++ b/api/all/src/test/java/io/opentelemetry/api/trace/TraceStateTest.java @@ -306,29 +306,29 @@ void removeNotPresent() { } @Test - void removeTwice() { + void removeSameKeyTwice() { assertThat(firstTraceState.toBuilder().remove(FIRST_KEY).remove(FIRST_KEY).build()) .isEqualTo(TraceState.getDefault()); } @Test - void removeTwice_KeepsRemainingEntry() { + void removeSameKeyTwice_KeepsRemainingEntry() { assertThat(multiValueTraceState.toBuilder().remove(FIRST_KEY).remove(FIRST_KEY).build().asMap()) .containsExactly(entry(SECOND_KEY, SECOND_VALUE)); } @Test - void removeTwice_KeepsRemainingEntries() { + void removeSameKeyTwice_KeepsRemainingEntries() { assertThat( TraceState.builder() .put(FIRST_KEY, FIRST_VALUE) .put(SECOND_KEY, SECOND_VALUE) .put(THIRD_KEY, THIRD_VALUE) - .remove(FIRST_KEY) - .remove(FIRST_KEY) + .remove(SECOND_KEY) + .remove(SECOND_KEY) .build() .asMap()) - .containsExactly(entry(THIRD_KEY, THIRD_VALUE), entry(SECOND_KEY, SECOND_VALUE)); + .containsExactly(entry(THIRD_KEY, THIRD_VALUE), entry(FIRST_KEY, FIRST_VALUE)); } @Test