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

2.x: Improve coverage, fix operator logic 03/12 #5910

Merged
merged 1 commit into from
Mar 13, 2018

Conversation

akarnokd
Copy link
Member

Improve coverage of RxJava internal components. See the change explanation as comments below.

@@ -278,7 +278,7 @@ public int size() {
* @param e the {@link Throwable} {@code e}.
* @return The root cause of {@code e}. If {@code e.getCause()} returns {@code null} or {@code e}, just return {@code e} itself.
*/
private Throwable getRootCause(Throwable e) {
/*private */Throwable getRootCause(Throwable e) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That cause == root case is borderline impossible, unless this method gets called with this.

b = buffer;
if (b == null) {
return;
if (DisposableHelper.replace(other, bs)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use dedicated helper instead of a CAS, plus the old code could unset a terminal indicator.

@@ -324,9 +320,10 @@ public void request(long n) {

@Override
public void cancel() {
clear();
cancelled = true;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cancelled is checked at various places but was never actually set.

@@ -58,7 +58,7 @@ protected void subscribeActual(Subscriber<? super T> s) {

Subscription s;

final SequentialDisposable timer = new SequentialDisposable();
Disposable timer;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timer is only manipulated from onNext, onError or onComplete and doesn't have to be atomically safe. The operator disposes the entire worker to stop any outstanding timer activity anyway.

b = buffer;
if (b == null) {
return;
if (DisposableHelper.replace(other, bs)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the helper method instead of a CAS that could replace a terminal indicator.

@@ -51,7 +51,7 @@ public void subscribeActual(Observer<? super T> t) {

Disposable s;

final AtomicReference<Disposable> timer = new AtomicReference<Disposable>();
Disposable timer;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timer is only manipulated from onNext, onError and onComplete.

@@ -85,12 +85,9 @@ public void onSubscribe(Disposable d) {
public void onSuccess(T value) {
other.dispose();

Disposable a = get();
Disposable a = getAndSet(DisposableHelper.DISPOSED);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be called at most once anyway, so biasing towards the a != DisposableHelper.DISPOSED being true.

@@ -58,8 +58,7 @@ public MergerBiFunction(Comparator<? super T> comparator) {
while (at.hasNext()) {
both.add(at.next());
}
} else
if (s2 != null) {
} else {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point either s1 or s2 can be null.

@akarnokd
Copy link
Member Author

Done with the explanations.

@codecov
Copy link

codecov bot commented Mar 12, 2018

Codecov Report

Merging #5910 into 2.x will increase coverage by 0.23%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #5910      +/-   ##
============================================
+ Coverage     98.03%   98.27%   +0.23%     
- Complexity     5992     6002      +10     
============================================
  Files           655      655              
  Lines         43928    43927       -1     
  Branches       6086     6084       -2     
============================================
+ Hits          43067    43169     +102     
+ Misses          258      223      -35     
+ Partials        603      535      -68
Impacted Files Coverage Δ Complexity Δ
.../io/reactivex/internal/functions/ObjectHelper.java 100% <ø> (ø) 21 <0> (ø) ⬇️
...a/io/reactivex/internal/util/MergerBiFunction.java 100% <ø> (+15.38%) 13 <0> (+2) ⬆️
...va/io/reactivex/exceptions/CompositeException.java 100% <ø> (+0.98%) 36 <0> (+1) ⬆️
...vex/internal/operators/single/SingleTakeUntil.java 100% <100%> (+3.33%) 2 <0> (ø) ⬇️
...s/observable/ObservableBufferBoundarySupplier.java 98.27% <100%> (+5.05%) 2 <0> (ø) ⬇️
...ternal/operators/flowable/FlowableBufferTimed.java 99.26% <100%> (+9.15%) 5 <0> (ø) ⬇️
.../operators/observable/ObservableDebounceTimed.java 98.64% <100%> (+4.28%) 2 <0> (ø) ⬇️
...nternal/operators/observable/ObservableBuffer.java 100% <100%> (+4.34%) 4 <0> (ø) ⬇️
...ators/flowable/FlowableBufferBoundarySupplier.java 95.93% <100%> (+6.33%) 2 <0> (ø) ⬇️
...rnal/operators/flowable/FlowableDebounceTimed.java 100% <100%> (+6.09%) 2 <0> (ø) ⬇️
... and 44 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ab52050...ba61278. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants