Skip to content

Commit f2239f7

Browse files
runningcodeclaude
andcommitted
ref(core): Sort breadcrumbs by their natural ordering in SentryClient
SortBreadcrumbsByDate compared timestamps only, so ties fell through to the sort's stability. Breadcrumb.compareTo now defines that same order with a defined tie-breaker, leaving the comparator a weaker duplicate of it and the codebase with two definitions of breadcrumb order. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent a2de9ab commit f2239f7

1 file changed

Lines changed: 1 addition & 12 deletions

File tree

sentry/src/main/java/io/sentry/SentryClient.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.util.ArrayList;
2727
import java.util.Collection;
2828
import java.util.Collections;
29-
import java.util.Comparator;
3029
import java.util.List;
3130
import java.util.Map;
3231
import org.jetbrains.annotations.ApiStatus;
@@ -41,7 +40,6 @@ public final class SentryClient implements ISentryClient {
4140

4241
private final @NotNull SentryOptions options;
4342
private final @NotNull ITransport transport;
44-
private final @NotNull SortBreadcrumbsByDate sortBreadcrumbsByDate = new SortBreadcrumbsByDate();
4543
private final @NotNull ILoggerBatchProcessor loggerBatchProcessor;
4644
private final @NotNull IMetricsBatchProcessor metricsBatchProcessor;
4745

@@ -1660,7 +1658,7 @@ private void sortBreadcrumbsByDate(
16601658

16611659
if (sortedBreadcrumbs != null && !breadcrumbs.isEmpty()) {
16621660
sortedBreadcrumbs.addAll(breadcrumbs);
1663-
Collections.sort(sortedBreadcrumbs, sortBreadcrumbsByDate);
1661+
Collections.sort(sortedBreadcrumbs);
16641662
}
16651663
}
16661664

@@ -1851,13 +1849,4 @@ private boolean sample() {
18511849
}
18521850
return true;
18531851
}
1854-
1855-
private static final class SortBreadcrumbsByDate implements Comparator<Breadcrumb> {
1856-
1857-
@SuppressWarnings({"JdkObsolete", "JavaUtilDate"})
1858-
@Override
1859-
public int compare(final @NotNull Breadcrumb b1, final @NotNull Breadcrumb b2) {
1860-
return b1.getTimestamp().compareTo(b2.getTimestamp());
1861-
}
1862-
}
18631852
}

0 commit comments

Comments
 (0)