-
-
Notifications
You must be signed in to change notification settings - Fork 435
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
Conversation
Excited about this change! |
Codecov Report
@@ Coverage Diff @@
## main #1439 +/- ##
============================================
- Coverage 75.87% 75.61% -0.27%
- Complexity 1901 1905 +4
============================================
Files 189 189
Lines 6499 6532 +33
Branches 640 659 +19
============================================
+ Hits 4931 4939 +8
- Misses 1272 1277 +5
- Partials 296 316 +20
Continue to review full report at Codecov.
|
sentry-android-core/src/main/java/io/sentry/android/core/AndroidLogger.java
Outdated
Show resolved
Hide resolved
@marandaneto have a look please. Since this is a breaking change anyway, perhaps we can re-evaluate if some parameters should/should not be nullable |
@@ -191,11 +191,10 @@ private void setThreads(final @NotNull SentryEvent event) { | |||
// crashed properly | |||
List<Long> mechanismThreadIds = null; | |||
|
|||
final boolean hasExceptions = | |||
event.getExceptions() != null && !event.getExceptions().isEmpty(); | |||
final List<SentryException> eventExceptions = event.getExceptions(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wondering why we've changed the hasExceptions
instead of checking NPE and emptiness 2 times
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NullAway
is not able to recognize this check. If we want to keep using it, we would either have to do it as in PR, or disable warning for this method.
@@ -26,7 +26,7 @@ public SendFireAndForgetEnvelopeSender( | |||
Objects.requireNonNull(options, "SentryOptions is required"); | |||
|
|||
final String dirPath = sendFireAndForgetDirPath.getDirPath(); | |||
if (!hasValidPath(dirPath, options.getLogger())) { | |||
if (dirPath == null || !hasValidPath(dirPath, options.getLogger())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasValidPath
already checks for NPE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same reason as here #1439 (comment)
@@ -26,7 +26,7 @@ public SendFireAndForgetOutboxSender( | |||
Objects.requireNonNull(options, "SentryOptions is required"); | |||
|
|||
final String dirPath = sendFireAndForgetDirPath.getDirPath(); | |||
if (!hasValidPath(dirPath, options.getLogger())) { | |||
if (dirPath == null || !hasValidPath(dirPath, options.getLogger())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same reason as here #1439 (comment)
|
Co-authored-by: Manoel Aranda Neto <[email protected]>
Few comments left to resolve and take decision. The rest is fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left my last notes over the open issues. Nothing major so I'm OK either way.
Since this is huge I'm just hoping we merge so:
😄
|
Merging this to move things! Looks like nothing major pending, but lets work on follow up PRs if something comes up |
📜 Description
Adds
@Nullable
&@NotNull
annotations to classes and interfaces insentry
module.💡 Motivation and Context
Better Kotlin interoperatibility and cleaner API.
💚 How did you test it?
With
NullAway
Errorprone plugin.I did not unfortunately find a way to ensure that API is 100% documented. Errorprone triggers violation if the null safety is violated in the code, but if the code is not used, it won't trigger an error.
📝 Checklist
Breaking changes affect mainly Kotlin users.
🔮 Next steps
Add nullability annotations to other modules - as PRs to
nullability
branch.