-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
2.x: Feature/#4876 more null checks #5055
2.x: Feature/#4876 more null checks #5055
Conversation
add assertion to help static code analysis
49d7a0c
to
79e9855
Compare
Codecov Report@@ Coverage Diff @@
## 2.x #5055 +/- ##
============================================
+ Coverage 95.53% 95.58% +0.05%
- Complexity 5540 5544 +4
============================================
Files 612 612
Lines 39576 39577 +1
Branches 5553 5554 +1
============================================
+ Hits 37807 37831 +24
+ Misses 775 754 -21
+ Partials 994 992 -2
Continue to review full report at Codecov.
|
@@ -73,6 +76,7 @@ public void subscribeActual(Subscriber<? super R> s) { | |||
Publisher<? extends T>[] a = array; | |||
int n; | |||
if (a == null) { | |||
assert iterable != null; //either array or iterable are initialized with non null values |
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.
Asserts are off by default but they increase the bytecode size; besides we don't use assert
it anyway.
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.
ok. removed it.
Do you have a standard way to suppress false positives?
@@ -246,6 +246,7 @@ public void onNext(T t) { | |||
|
|||
if (i == size) { | |||
window = null; | |||
assert w != null; |
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.
Please remove these asserts.
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.
done
super(source); | ||
this.otherArray = otherArray; | ||
this.otherIterable = null; | ||
this.combiner = combiner; | ||
} | ||
|
||
public FlowableWithLatestFromMany(Publisher<T> source, Iterable<? extends Publisher<?>> otherIterable, Function<? super Object[], R> combiner) { | ||
public FlowableWithLatestFromMany(@NonNull Publisher<T> source, @NonNull Iterable<? extends Publisher<?>> otherIterable, Function<? super Object[], R> combiner) { |
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.
combiner
needs annotation
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.
done
@@ -115,4 +115,18 @@ public void run() { | |||
|
|||
assertEquals(0, calls[0]); | |||
} | |||
|
|||
@Test | |||
public void npe() throws Exception { |
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.
This could be named a bit more informatively.
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.
yep. added some comments
05d5986
to
339b6b8
Compare
I have added some more null checks to help the static code analysis.
I think I have also fixed one possible NPE in NewThreadWorker