Skip to content

Commit

Permalink
Prevent NPE by checking SentryTracer.timer for null again inside sync…
Browse files Browse the repository at this point in the history
…hronized (#2200)
  • Loading branch information
adinauer committed Aug 3, 2022
1 parent 2759ef9 commit 4eb446a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Fixes

- Prevent NPE by checking SentryTracer.timer for null again inside synchronized ([#2200](https://github.com/getsentry/sentry-java/pull/2200))
- `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
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 @@ -344,8 +344,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 4eb446a

Please sign in to comment.