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

Add nullability annotations to sentry module. #1439

Merged
merged 44 commits into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
6ee802c
Add NullAway plugin.
maciejwalkowiak Apr 23, 2021
58f727a
Add nullability annotations for `App`, `Request`, `SentryId`.
maciejwalkowiak Apr 23, 2021
4810f24
Add nullability annotations for `Browser`, `Device`, `OperatingSystem`.
maciejwalkowiak Apr 23, 2021
bc25307
Refactor
maciejwalkowiak Apr 23, 2021
fed90f6
Fix tests.
maciejwalkowiak Apr 23, 2021
fff6e0d
Add nullability annotations for `Gpu`, `SentryRuntime`, `SentrySpan`.
maciejwalkowiak Apr 23, 2021
d41f15f
Add nullability annotations for `Message`, `SentryThread`.
maciejwalkowiak Apr 26, 2021
129cbab
Merge remote-tracking branch 'origin/main' into nullability
maciejwalkowiak Apr 28, 2021
106c3e1
Add nullability annotations for `DebugMeta`, `SdkInfo`, `SentryExcept…
maciejwalkowiak Apr 28, 2021
0411d37
Add nullability annotations for the rest of the protocol package.
maciejwalkowiak Apr 29, 2021
2cf4f90
Add nullability annotations to `transport` package.
maciejwalkowiak Apr 29, 2021
3c73221
Add nullability annotations to `util` package.
maciejwalkowiak Apr 29, 2021
5bc9b98
Add nullability annotations to `transport` package.
maciejwalkowiak Apr 30, 2021
37a1274
Add nullability annotations to `SentrySpan`
maciejwalkowiak Apr 30, 2021
f19c1c5
Add nullability annotations.
maciejwalkowiak Apr 30, 2021
69f707e
Add nullability annotations to `ISerializer`
maciejwalkowiak Apr 30, 2021
98f5049
Add nullability annotations.
maciejwalkowiak Apr 30, 2021
ef5dcde
Add nullability annotations to `adapters` package. (#1448)
maciejwalkowiak Apr 30, 2021
c4daf63
Add nullability annotations to `SentryEvent`, `SentryBaseEvent`.
maciejwalkowiak Apr 30, 2021
b042b91
Merge remote-tracking branch 'origin/nullability' into nullability-tr…
maciejwalkowiak Apr 30, 2021
65bdc22
Add nullability annotations.
maciejwalkowiak May 3, 2021
dee5772
Add nullability annotations to logger classes.
maciejwalkowiak May 3, 2021
69726a0
Add nullability annotations.
maciejwalkowiak May 3, 2021
d6fcfef
Add nullability annotations.
maciejwalkowiak May 3, 2021
9642217
Add nullability annotations to `SentryClient`
maciejwalkowiak May 3, 2021
90cba1a
Add nullability annotations.
maciejwalkowiak May 3, 2021
817e5b4
Polish tests.
maciejwalkowiak May 3, 2021
3c87b97
Handle `Scope#setTransaction` with `null`
maciejwalkowiak May 3, 2021
7aa2add
Polish.
maciejwalkowiak May 3, 2021
099dbab
Polish.
maciejwalkowiak May 3, 2021
57d0c74
Polish.
maciejwalkowiak May 5, 2021
66aa861
Update sentry/src/main/java/io/sentry/cache/EnvelopeCache.java
maciejwalkowiak May 7, 2021
246faf0
Fix logger nullability.
maciejwalkowiak May 7, 2021
a951170
Fix Scope#setTransaction nullability.
maciejwalkowiak May 7, 2021
2bfb639
Add explanation why NullAway is suppressed.
maciejwalkowiak May 7, 2021
71eca42
Polish.
maciejwalkowiak May 7, 2021
3da98b1
Drop InvalidDsnException.
maciejwalkowiak May 7, 2021
c764eb9
Polish.
maciejwalkowiak May 7, 2021
c5473c0
Polish `EnvelopeReader`.
maciejwalkowiak May 7, 2021
f64c188
Polish.
maciejwalkowiak May 7, 2021
744425c
Changelog.
maciejwalkowiak May 7, 2021
e1b1f7e
Merge remote-tracking branch 'origin/main' into nullability
maciejwalkowiak May 10, 2021
b577af5
release on Session is not null
maciejwalkowiak May 10, 2021
f05a251
Merge remote-tracking branch 'origin/main' into nullability
maciejwalkowiak May 10, 2021
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
2 changes: 2 additions & 0 deletions buildSrc/src/main/java/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ object Config {
val mockitoInline = "org.mockito:mockito-inline:3.8.0"
val awaitility = "org.awaitility:awaitility-kotlin:4.0.3"
val mockWebserver = "com.squareup.okhttp3:mockwebserver:4.9.0"
val jsonUnit = "net.javacrumbs.json-unit:json-unit:2.11.1"
}

object QualityPlugins {
Expand Down Expand Up @@ -143,6 +144,7 @@ object Config {
val nopenChecker = "com.jakewharton.nopen:nopen-checker:$nopenVersion"
val errorprone = "com.google.errorprone:error_prone_core:2.5.1"
val errorProneJavac8 = "com.google.errorprone:javac:9+181-r4173-1"
val errorProneNullAway = "com.uber.nullaway:nullaway:0.9.1"
}

object NativePlugins {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ final class AndroidLogger implements ILogger {

@SuppressWarnings("AnnotateFormatMethod")
@Override
public void log(SentryLevel level, String message, Object... args) {
public void log(
final @Nullable SentryLevel level,
maciejwalkowiak marked this conversation as resolved.
Show resolved Hide resolved
final @Nullable String message,
maciejwalkowiak marked this conversation as resolved.
Show resolved Hide resolved
final @Nullable Object... args) {
Log.println(toLogcatLevel(level), tag, String.format(message, args));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,12 @@ class DefaultAndroidEventProcessorTest {

assertNotNull(sut.process(SentryEvent(), null)) {
assertNotNull(it.contexts.app)
assertEquals("test", it.debugMeta.images[0].uuid)
assertNotNull(it.dist)
assertNotNull(it.debugMeta) { debugMeta ->
assertNotNull(debugMeta.images) { images ->
assertEquals("test", images[0].uuid)
}
}
}
}

Expand All @@ -129,7 +133,11 @@ class DefaultAndroidEventProcessorTest {
}

assertNotNull(sut.process(event, null)) {
assertEquals("test", it.debugMeta.images[0].uuid)
assertNotNull(it.debugMeta) { debugMeta ->
assertNotNull(debugMeta.images) { images ->
assertEquals("test", images[0].uuid)
}
}
}
}

Expand All @@ -148,8 +156,12 @@ class DefaultAndroidEventProcessorTest {
}

assertNotNull(sut.process(event, null)) {
assertEquals("abc", it.debugMeta.images.first().uuid)
assertEquals("test", it.debugMeta.images.last().uuid)
assertNotNull(it.debugMeta) { debugMeta ->
assertNotNull(debugMeta.images) { images ->
assertEquals("abc", images.first().uuid)
assertEquals("test", images.last().uuid)
}
}
}
}

Expand All @@ -165,7 +177,9 @@ class DefaultAndroidEventProcessorTest {
}

assertNotNull(sut.process(event, null)) {
assertTrue(it.threads.first().isCurrent)
assertNotNull(it.threads) { threads ->
assertTrue(threads.first().isCurrent == true)
}
}
}

Expand All @@ -180,7 +194,9 @@ class DefaultAndroidEventProcessorTest {
}

assertNotNull(sut.process(event, null)) {
assertFalse(it.threads.first().isCurrent)
assertNotNull(it.threads) { threads ->
assertFalse(threads.first().isCurrent == true)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import io.sentry.getExc
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
import kotlin.test.assertNull
import kotlin.test.assertTrue
import timber.log.Timber
Expand Down Expand Up @@ -165,7 +166,9 @@ class SentryTimberTreeTest {
val sut = fixture.getSut()
sut.e("message")
verify(fixture.hub).captureEvent(check {
assertEquals("message", it.message.formatted)
assertNotNull(it.message) { message ->
assertEquals("message", message.formatted)
}
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.hc.core5.io.CloseMode;
import org.apache.hc.core5.util.TimeValue;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
* {@link ITransport} implementation that executes request asynchronously in a non-blocking manner
Expand Down Expand Up @@ -62,7 +63,8 @@ public ApacheHttpClientTransport(

@Override
@SuppressWarnings("FutureReturnValueIgnored")
public void send(SentryEnvelope envelope, Object hint) throws IOException {
public void send(final @NotNull SentryEnvelope envelope, final @Nullable Object hint)
throws IOException {
if (isSchedulingAllowed()) {
final SentryEnvelope filteredEnvelope = rateLimiter.filter(envelope, hint);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ApacheHttpClientTransportFactory(final @NotNull TimeValue connectionTimeT
}

@Override
public ITransport create(
public @NotNull ITransport create(
final @NotNull SentryOptions options, final @NotNull RequestDetails requestDetails) {
Objects.requireNonNull(options, "options is required");
Objects.requireNonNull(requestDetails, "requestDetails is required");
Expand Down
52 changes: 31 additions & 21 deletions sentry-jul/src/test/kotlin/io/sentry/jul/SentryHandlerTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ class SentryHandlerTest {

await.untilAsserted {
verify(fixture.transport).send(checkEvent { event ->
assertEquals("testing message conversion 1, 2", event.message.formatted)
assertEquals("testing message conversion {0}, {1}", event.message.message)
assertEquals(listOf("1", "2"), event.message.params)
assertNotNull(event.message) { message ->
assertEquals("testing message conversion 1, 2", message.formatted)
assertEquals("testing message conversion {0}, {1}", message.message)
assertEquals(listOf("1", "2"), message.params)
}
assertEquals("jul.SentryHandlerTest", event.logger)
}, anyOrNull())
}
Expand All @@ -95,9 +97,11 @@ class SentryHandlerTest {

await.untilAsserted {
verify(fixture.transport).send(checkEvent { event ->
assertEquals("testing message conversion 1, 2", event.message.formatted)
assertEquals("testing message conversion {0}, {1}", event.message.message)
assertEquals(listOf("1", "2"), event.message.params)
assertNotNull(event.message) { message ->
assertEquals("testing message conversion 1, 2", message.formatted)
assertEquals("testing message conversion {0}, {1}", message.message)
assertEquals(listOf("1", "2"), message.params)
}
assertEquals("jul.SentryHandlerTest", event.logger)
}, anyOrNull())
}
Expand Down Expand Up @@ -205,16 +209,18 @@ class SentryHandlerTest {

await.untilAsserted {
verify(fixture.transport).send(checkEvent { event ->
assertEquals(2, event.breadcrumbs.size)
val breadcrumb = event.breadcrumbs[0]
val breadcrumbTime = Instant.ofEpochMilli(event.timestamp.time)
.atZone(ZoneId.of("UTC"))
.toLocalDateTime()
assertTrue { breadcrumbTime.plusSeconds(1).isAfter(utcTime) }
assertTrue { breadcrumbTime.minusSeconds(1).isBefore(utcTime) }
assertEquals("this should be a breadcrumb #1", breadcrumb.message)
assertEquals("jul.SentryHandlerTest", breadcrumb.category)
assertEquals(SentryLevel.DEBUG, breadcrumb.level)
assertNotNull(event.breadcrumbs) { breadcrumbs ->
assertEquals(2, breadcrumbs.size)
val breadcrumb = breadcrumbs[0]
val breadcrumbTime = Instant.ofEpochMilli(event.timestamp.time)
.atZone(ZoneId.of("UTC"))
.toLocalDateTime()
assertTrue { breadcrumbTime.plusSeconds(1).isAfter(utcTime) }
assertTrue { breadcrumbTime.minusSeconds(1).isBefore(utcTime) }
assertEquals("this should be a breadcrumb #1", breadcrumb.message)
assertEquals("jul.SentryHandlerTest", breadcrumb.category)
assertEquals(SentryLevel.DEBUG, breadcrumb.level)
}
}, anyOrNull())
}
}
Expand All @@ -229,8 +235,10 @@ class SentryHandlerTest {

await.untilAsserted {
verify(fixture.transport).send(checkEvent { event ->
assertEquals(1, event.breadcrumbs.size)
assertEquals("this should be a breadcrumb", event.breadcrumbs[0].message)
assertNotNull(event.breadcrumbs) { breadcrumbs ->
assertEquals(1, breadcrumbs.size)
assertEquals("this should be a breadcrumb", breadcrumbs[0].message)
}
}, anyOrNull())
}
}
Expand All @@ -246,9 +254,11 @@ class SentryHandlerTest {

await.untilAsserted {
verify(fixture.transport).send(checkEvent { event ->
assertEquals(2, event.breadcrumbs.size)
assertEquals("this should be a breadcrumb", event.breadcrumbs[0].message)
assertEquals("this should not be sent as the event but be a breadcrumb", event.breadcrumbs[1].message)
assertNotNull(event.breadcrumbs) { breadcrumbs ->
assertEquals(2, breadcrumbs.size)
assertEquals("this should be a breadcrumb", breadcrumbs[0].message)
assertEquals("this should not be sent as the event but be a breadcrumb", breadcrumbs[1].message)
}
}, anyOrNull())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ class SentryAppenderTest {

await.untilAsserted {
verify(fixture.transport).send(checkEvent { event ->
assertEquals("testing message conversion 1, 2", event.message.formatted)
assertEquals("testing message conversion {}, {}", event.message.message)
assertEquals(listOf("1", "2"), event.message.params)
assertNotNull(event.message) { message ->
assertEquals("testing message conversion 1, 2", message.formatted)
assertEquals("testing message conversion {}, {}", message.message)
assertEquals(listOf("1", "2"), message.params)
}
assertEquals("io.sentry.log4j2.SentryAppenderTest", event.logger)
}, anyOrNull())
}
Expand Down Expand Up @@ -270,16 +272,18 @@ class SentryAppenderTest {

await.untilAsserted {
verify(fixture.transport).send(checkEvent { event ->
assertEquals(2, event.breadcrumbs.size)
val breadcrumb = event.breadcrumbs[0]
val breadcrumbTime = Instant.ofEpochMilli(event.timestamp.time)
.atZone(fixture.utcTimeZone)
.toLocalDateTime()
assertTrue { breadcrumbTime.plusSeconds(1).isAfter(utcTime) }
assertTrue { breadcrumbTime.minusSeconds(1).isBefore(utcTime) }
assertEquals("this should be a breadcrumb #1", breadcrumb.message)
assertEquals("io.sentry.log4j2.SentryAppenderTest", breadcrumb.category)
assertEquals(SentryLevel.DEBUG, breadcrumb.level)
assertNotNull(event.breadcrumbs) { breadcrumbs ->
assertEquals(2, breadcrumbs.size)
val breadcrumb = breadcrumbs[0]
val breadcrumbTime = Instant.ofEpochMilli(event.timestamp.time)
.atZone(fixture.utcTimeZone)
.toLocalDateTime()
assertTrue { breadcrumbTime.plusSeconds(1).isAfter(utcTime) }
assertTrue { breadcrumbTime.minusSeconds(1).isBefore(utcTime) }
assertEquals("this should be a breadcrumb #1", breadcrumb.message)
assertEquals("io.sentry.log4j2.SentryAppenderTest", breadcrumb.category)
assertEquals(SentryLevel.DEBUG, breadcrumb.level)
}
}, anyOrNull())
}
}
Expand All @@ -294,8 +298,10 @@ class SentryAppenderTest {

await.untilAsserted {
verify(fixture.transport).send(checkEvent { event ->
assertEquals(1, event.breadcrumbs.size)
assertEquals("this should be a breadcrumb", event.breadcrumbs[0].message)
assertNotNull(event.breadcrumbs) { breadcrumbs ->
assertEquals(1, breadcrumbs.size)
assertEquals("this should be a breadcrumb", breadcrumbs[0].message)
}
}, anyOrNull())
}
}
Expand All @@ -311,9 +317,11 @@ class SentryAppenderTest {

await.untilAsserted {
verify(fixture.transport).send(checkEvent { event ->
assertEquals(2, event.breadcrumbs.size)
assertEquals("this should be a breadcrumb", event.breadcrumbs[0].message)
assertEquals("this should not be sent as the event but be a breadcrumb", event.breadcrumbs[1].message)
assertNotNull(event.breadcrumbs) { breadcrumbs ->
assertEquals(2, breadcrumbs.size)
assertEquals("this should be a breadcrumb", breadcrumbs[0].message)
assertEquals("this should not be sent as the event but be a breadcrumb", breadcrumbs[1].message)
}
}, anyOrNull())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ class SentryAppenderTest {

await.untilAsserted {
verify(fixture.transport).send(checkEvent { event ->
assertEquals("testing message conversion 1, 2", event.message.formatted)
assertEquals("testing message conversion {}, {}", event.message.message)
assertEquals(listOf("1", "2"), event.message.params)
assertNotNull(event.message) { message ->
assertEquals("testing message conversion 1, 2", message.formatted)
assertEquals("testing message conversion {}, {}", message.message)
assertEquals(listOf("1", "2"), message.params)
}
assertEquals("io.sentry.logback.SentryAppenderTest", event.logger)
}, anyOrNull())
}
Expand Down Expand Up @@ -262,16 +264,18 @@ class SentryAppenderTest {

await.untilAsserted {
verify(fixture.transport).send(checkEvent { event ->
assertEquals(2, event.breadcrumbs.size)
val breadcrumb = event.breadcrumbs[0]
val breadcrumbTime = Instant.ofEpochMilli(event.timestamp.time)
.atZone(fixture.utcTimeZone)
.toLocalDateTime()
assertTrue { breadcrumbTime.plusSeconds(1).isAfter(utcTime) }
assertTrue { breadcrumbTime.minusSeconds(1).isBefore(utcTime) }
assertEquals("this should be a breadcrumb #1", breadcrumb.message)
assertEquals("io.sentry.logback.SentryAppenderTest", breadcrumb.category)
assertEquals(SentryLevel.DEBUG, breadcrumb.level)
assertNotNull(event.breadcrumbs) { breadcrumbs ->
assertEquals(2, breadcrumbs.size)
val breadcrumb = breadcrumbs[0]
val breadcrumbTime = Instant.ofEpochMilli(event.timestamp.time)
.atZone(fixture.utcTimeZone)
.toLocalDateTime()
assertTrue { breadcrumbTime.plusSeconds(1).isAfter(utcTime) }
assertTrue { breadcrumbTime.minusSeconds(1).isBefore(utcTime) }
assertEquals("this should be a breadcrumb #1", breadcrumb.message)
assertEquals("io.sentry.logback.SentryAppenderTest", breadcrumb.category)
assertEquals(SentryLevel.DEBUG, breadcrumb.level)
}
}, anyOrNull())
}
}
Expand All @@ -286,8 +290,10 @@ class SentryAppenderTest {

await.untilAsserted {
verify(fixture.transport).send(checkEvent { event ->
assertEquals(1, event.breadcrumbs.size)
assertEquals("this should be a breadcrumb", event.breadcrumbs[0].message)
assertNotNull(event.breadcrumbs) { breadcrumbs ->
assertEquals(1, breadcrumbs.size)
assertEquals("this should be a breadcrumb", breadcrumbs[0].message)
}
}, anyOrNull())
}
}
Expand All @@ -303,9 +309,11 @@ class SentryAppenderTest {

await.untilAsserted {
verify(fixture.transport).send(checkEvent { event ->
assertEquals(2, event.breadcrumbs.size)
assertEquals("this should be a breadcrumb", event.breadcrumbs[0].message)
assertEquals("this should not be sent as the event but be a breadcrumb", event.breadcrumbs[1].message)
assertNotNull(event.breadcrumbs) { breadcrumbs ->
assertEquals(2, breadcrumbs.size)
assertEquals("this should be a breadcrumb", breadcrumbs[0].message)
assertEquals("this should not be sent as the event but be a breadcrumb", breadcrumbs[1].message)
}
}, anyOrNull())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,14 @@ class SentryRequestHttpServletRequestProcessorTest {

eventProcessor.process(event, null)

assertNotNull(event.request) {
assertFalse(it.headers.containsKey("X-FORWARDED-FOR"))
assertFalse(it.headers.containsKey("Authorization"))
assertFalse(it.headers.containsKey("authorization"))
assertFalse(it.headers.containsKey("Cookies"))
assertTrue(it.headers.containsKey("some-header"))
assertNotNull(event.request) { request ->
assertNotNull(request.headers) {
assertFalse(it.containsKey("X-FORWARDED-FOR"))
assertFalse(it.containsKey("Authorization"))
assertFalse(it.containsKey("authorization"))
assertFalse(it.containsKey("Cookies"))
assertTrue(it.containsKey("some-header"))
}
}
}
}
Loading