Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix old profiles deletion on SDK init #3216

Merged
merged 4 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 4 additions & 1 deletion sentry/src/main/java/io/sentry/Sentry.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down
Loading