Skip to content

Commit 7681822

Browse files
authored
Fixes bug where Span.Builder.duration wasn't cleared (openzipkin#1659)
1 parent 94eb930 commit 7681822

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

zipkin/src/main/java/zipkin/Span.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ public Builder clear() {
205205
id = null;
206206
parentId = null;
207207
timestamp = null;
208+
duration = null;
208209
if (annotations != null) annotations.clear();
209210
if (binaryAnnotations != null) binaryAnnotations.clear();
210211
debug = null;

zipkin/src/test/java/zipkin/SpanTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import java.io.ObjectInputStream;
1717
import java.io.ObjectOutputStream;
18+
import java.util.ArrayList;
1819
import java.util.Arrays;
1920
import okio.Buffer;
2021
import okio.ByteString;
@@ -64,6 +65,18 @@ public void spanNamesLowercase() {
6465
.isEqualTo("get");
6566
}
6667

68+
@Test
69+
public void clearBuilder_retainsEmptyCollections() {
70+
Span.Builder builder = TestObjects.TRACE.get(1).toBuilder();
71+
72+
// clear should set everything null, but retain empty collections
73+
Span.Builder expected = Span.builder();
74+
expected.annotations = new ArrayList<>();
75+
expected.binaryAnnotations = new ArrayList<>();
76+
assertThat(builder.clear())
77+
.isEqualToComparingFieldByField(expected);
78+
}
79+
6780
@Test
6881
public void mergeWhenBinaryAnnotationsSentSeparately() {
6982
Span part1 = Span.builder()

0 commit comments

Comments
 (0)