Skip to content

Commit

Permalink
Fix SentryTransaction#getStatus NPE (#1273)
Browse files Browse the repository at this point in the history
Fixes #1268.
  • Loading branch information
maciejwalkowiak authored Feb 19, 2021
1 parent e0e8be8 commit 1e7be93
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* Fix: Make the ANR Atomic flags immutable
* Enchancement: Integration interface better compatibility with Kotlin null-safety
* Enchancement: Simplify Sentry configuration in Spring integration (#1259)
* Fix: Fix SentryTransaction#getStatus NPE (#1273)
* Enchancement: Optimize SentryTracingFilter when hub is disabled.

Breaking Changes:
Expand Down
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/SentryTransaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ Date getTimestamp() {
@Override
@Nullable
public SpanStatus getStatus() {
return this.getContexts().getTrace().getStatus();
return context.getStatus();
}

@Override
Expand Down
13 changes: 13 additions & 0 deletions sentry/src/test/java/io/sentry/SentryTransactionTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,17 @@ class SentryTransactionTest {
transaction.name = "new name"
assertEquals("new name", transaction.transaction)
}

@Test
fun `when transaction is not finished, status is null`() {
val transaction = SentryTransaction("name", "op")
assertNull(transaction.status)
}

@Test
fun `when transaction is not finished, status can be read`() {
val transaction = SentryTransaction("name", "op")
transaction.status = SpanStatus.ABORTED
assertEquals(SpanStatus.ABORTED, transaction.status)
}
}

0 comments on commit 1e7be93

Please sign in to comment.