Skip to content

Commit c18a74d

Browse files
committed
Add object comparison to SpanFrameMetricsCollector only check for time difference of .equals if objects are not the same
1 parent 3bae1d7 commit c18a74d

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

sentry-android-core/src/main/java/io/sentry/android/core/SpanFrameMetricsCollector.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,19 @@ public class SpanFrameMetricsCollector
4545
private final @NotNull SortedSet<ISpan> runningSpans =
4646
new TreeSet<>(
4747
(o1, o2) -> {
48+
if (o1 == o2) {
49+
return 0;
50+
}
4851
int timeDiff = o1.getStartDate().compareTo(o2.getStartDate());
4952
if (timeDiff != 0) {
5053
return timeDiff;
51-
} else {
52-
// TreeSet uses compareTo to check for duplicates, so ensure that
53-
// two non-equal spans with the same start date are not considered equal
54-
return o1.getSpanContext()
55-
.getSpanId()
56-
.toString()
57-
.compareTo(o2.getSpanContext().getSpanId().toString());
5854
}
55+
// TreeSet uses compareTo to check for duplicates, so ensure that
56+
// two non-equal spans with the same start date are not considered equal
57+
return o1.getSpanContext()
58+
.getSpanId()
59+
.toString()
60+
.compareTo(o2.getSpanContext().getSpanId().toString());
5961
});
6062

6163
// all collected frames, sorted by frame end time

0 commit comments

Comments
 (0)