Skip to content

Commit

Permalink
Merge branch 'main' into feat/profiling-sample-rate
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanosiano authored Aug 5, 2022
2 parents e9ceb30 + eba572a commit 88ceb6d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Changelog

## Unreleased
## 6.3.1

### Fixes

- Prevent NPE by checking SentryTracer.timer for null again inside synchronized ([#2200](https://github.com/getsentry/sentry-java/pull/2200))
- Weakly reference Activity for transaction finished callback ([#2203](https://github.com/getsentry/sentry-java/pull/2203))
- `attach-screenshot` set on Manual init. didn't work ([#2186](https://github.com/getsentry/sentry-java/pull/2186))
- Remove extra space from `spring.factories` causing issues in old versions of Spring Boot ([#2181](https://github.com/getsentry/sentry-java/pull/2181))

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ org.gradle.parallel=true
android.useAndroidX=true

# Release information
versionName=6.3.0
versionName=6.3.1

# Override the SDK name on native crashes on Android
sentryAndroidSdkName=sentry.native.android
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.sentry.util.Objects;
import java.io.Closeable;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.Date;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -146,6 +147,7 @@ private void stopPreviousTransactions() {
}

private void startTracing(final @NotNull Activity activity) {
WeakReference<Activity> weakActivity = new WeakReference<>(activity);
if (performanceEnabled && !isRunningTransaction(activity) && hub != null) {
// as we allow a single transaction running on the bound Scope, we finish the previous ones
stopPreviousTransactions();
Expand All @@ -167,7 +169,20 @@ private void startTracing(final @NotNull Activity activity) {
(Date) null,
true,
(finishingTransaction) -> {
activityFramesTracker.setMetrics(activity, finishingTransaction.getEventId());
@Nullable Activity unwrappedActivity = weakActivity.get();
if (unwrappedActivity != null) {
activityFramesTracker.setMetrics(
unwrappedActivity, finishingTransaction.getEventId());
} else {
if (options != null) {
options
.getLogger()
.log(
SentryLevel.WARNING,
"Unable to track activity frames as the Activity %s has been destroyed.",
activityName);
}
}
});
} else {
// start transaction with app start timestamp
Expand All @@ -178,7 +193,20 @@ private void startTracing(final @NotNull Activity activity) {
appStartTime,
true,
(finishingTransaction) -> {
activityFramesTracker.setMetrics(activity, finishingTransaction.getEventId());
@Nullable Activity unwrappedActivity = weakActivity.get();
if (unwrappedActivity != null) {
activityFramesTracker.setMetrics(
unwrappedActivity, finishingTransaction.getEventId());
} else {
if (options != null) {
options
.getLogger()
.log(
SentryLevel.WARNING,
"Unable to track activity frames as the Activity %s has been destroyed.",
activityName);
}
}
});
// start specific span for app start

Expand Down
10 changes: 6 additions & 4 deletions sentry/src/main/java/io/sentry/SentryTracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public final class SentryTracer implements ITransaction {
*/
private final @Nullable Long idleTimeout;

private @Nullable TimerTask timerTask;
private @Nullable Timer timer = null;
private volatile @Nullable TimerTask timerTask;
private volatile @Nullable Timer timer = null;
private final @NotNull Object timerLock = new Object();
private final @NotNull SpanByTimestampComparator spanByTimestampComparator =
new SpanByTimestampComparator();
Expand Down Expand Up @@ -340,8 +340,10 @@ public void finish(@Nullable SpanStatus status) {

if (timer != null) {
synchronized (timerLock) {
timer.cancel();
timer = null;
if (timer != null) {
timer.cancel();
timer = null;
}
}
}

Expand Down

0 comments on commit 88ceb6d

Please sign in to comment.