From 8cfe149eb5e4667cc189010c5ffe985638fcc901 Mon Sep 17 00:00:00 2001 From: stefanosiano Date: Wed, 21 Feb 2024 13:14:26 +0100 Subject: [PATCH 1/3] profiles deleted on init now need to be at least 5 minutes older than the class creation time to account for app start profiles --- sentry/src/main/java/io/sentry/Sentry.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sentry/src/main/java/io/sentry/Sentry.java b/sentry/src/main/java/io/sentry/Sentry.java index deb01f72f9..e1f386e829 100644 --- a/sentry/src/main/java/io/sentry/Sentry.java +++ b/sentry/src/main/java/io/sentry/Sentry.java @@ -32,6 +32,7 @@ import java.util.List; import java.util.Properties; import java.util.concurrent.RejectedExecutionException; +import java.util.concurrent.TimeUnit; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -427,7 +428,9 @@ private static boolean initConfigurations(final @NotNull SentryOptions options) // Method trace files are normally deleted at the end of traces, but if that fails // for some reason we try to clear any old files here. for (File f : oldTracesDirContent) { - if (f.lastModified() < classCreationTimestamp) { + // We delete files 5 minutes older than class creation to account for app + // start profiles, as an app start profile could have a lower creation date. + if (f.lastModified() < classCreationTimestamp - TimeUnit.MINUTES.toMillis(5)) { FileUtils.deleteRecursively(f); } } From c6672879c5515001c7b8d2f414b6bd5bd202061b Mon Sep 17 00:00:00 2001 From: stefanosiano Date: Wed, 21 Feb 2024 13:16:47 +0100 Subject: [PATCH 2/3] updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77c28a927b..7573c8b7f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ ### Fixes +- Fix old profiles deletion on SDK init ([#3216](https://github.com/getsentry/sentry-java/pull/3216)) - Don't wait on main thread when SDK restarts ([#3200](https://github.com/getsentry/sentry-java/pull/3200)) - Fix Jetpack Compose widgets are not being correctly identified for user interaction tracing ([#3209](https://github.com/getsentry/sentry-java/pull/3209)) - Fix issue title on Android when a wrapping `RuntimeException` is thrown by the system ([#3212](https://github.com/getsentry/sentry-java/pull/3212)) From 8be1e86d6e99d9fe94fa8a68c41a8c78058c2e4c Mon Sep 17 00:00:00 2001 From: Stefano Date: Wed, 21 Feb 2024 14:44:31 +0100 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad14771227..d557f71dd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixes + +- Fix old profiles deletion on SDK init ([#3216](https://github.com/getsentry/sentry-java/pull/3216)) + ## 7.4.0 ### Features @@ -14,7 +20,6 @@ ### Fixes -- Fix old profiles deletion on SDK init ([#3216](https://github.com/getsentry/sentry-java/pull/3216)) - Don't wait on main thread when SDK restarts ([#3200](https://github.com/getsentry/sentry-java/pull/3200)) - Fix Jetpack Compose widgets are not being correctly identified for user interaction tracing ([#3209](https://github.com/getsentry/sentry-java/pull/3209)) - Fix issue title on Android when a wrapping `RuntimeException` is thrown by the system ([#3212](https://github.com/getsentry/sentry-java/pull/3212))