Skip to content

Commit

Permalink
Fix old profiles deletion on SDK init (#3216)
Browse files Browse the repository at this point in the history
* profiles deleted on init now need to be at least 5 minutes older than the class creation time to account for app start profiles
  • Loading branch information
stefanosiano committed Feb 21, 2024
1 parent 3e3bf45 commit c34791a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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

0 comments on commit c34791a

Please sign in to comment.