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.: Fix flatMapX over-cancellation in case of an inner error #4686

Merged
merged 1 commit into from
Oct 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ jacoco {
toolVersion = '0.7.7.201606060606' // See http://www.eclemma.org/jacoco/.
}

task GCandMem(dependsOn: 'check') << {
System.gc()
Thread.sleep(200)
print("Memory usage: ")
println(java.lang.management.ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed() / 1024.0 / 1024.0)
}

jacocoTestReport {
reports {
xml.enabled = true
Expand All @@ -129,6 +136,8 @@ jacocoTestReport {
}
}

jacocoTestReport.dependsOn GCandMem

build.dependsOn jacocoTestReport

// pmd {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ void innerError(InnerObserver inner, Throwable e) {
set.delete(inner);
if (errors.addThrowable(e)) {
if (!delayErrors) {
cancel();
s.cancel();
set.dispose();
}
active.decrementAndGet();
drain();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ void innerError(InnerObserver inner, Throwable e) {
set.delete(inner);
if (errors.addThrowable(e)) {
if (!delayErrors) {
cancel();
s.cancel();
set.dispose();
}
active.decrementAndGet();
drain();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ void innerError(InnerObserver inner, Throwable e) {
set.delete(inner);
if (errors.addThrowable(e)) {
if (!delayErrors) {
dispose();
d.dispose();
set.dispose();
}
active.decrementAndGet();
drain();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ void innerError(InnerObserver inner, Throwable e) {
set.delete(inner);
if (errors.addThrowable(e)) {
if (!delayErrors) {
dispose();
d.dispose();
set.dispose();
}
active.decrementAndGet();
drain();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import static org.junit.Assert.*;

import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.*;

import org.junit.Test;

Expand Down Expand Up @@ -253,4 +253,22 @@ public MaybeSource<Integer> apply(Integer v) throws Exception {
.test()
.assertResult(1, 2);
}

@Test
public void middleError() {
Flowable.fromArray(new String[]{"1","a","2"}).flatMapMaybe(new Function<String, MaybeSource<Integer>>() {
@Override
public MaybeSource<Integer> apply(final String s) throws NumberFormatException {
//return Single.just(Integer.valueOf(s)); //This works
return Maybe.fromCallable(new Callable<Integer>() {
@Override
public Integer call() throws NumberFormatException {
return Integer.valueOf(s);
}
});
}
})
.test()
.assertFailure(NumberFormatException.class, 1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import static org.junit.Assert.*;

import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.*;

import org.junit.Test;

Expand Down Expand Up @@ -240,4 +240,22 @@ public SingleSource<Integer> apply(Integer v) throws Exception {
.test()
.assertResult(1, 2);
}

@Test
public void middleError() {
Flowable.fromArray(new String[]{"1","a","2"}).flatMapSingle(new Function<String, SingleSource<Integer>>() {
@Override
public SingleSource<Integer> apply(final String s) throws NumberFormatException {
//return Single.just(Integer.valueOf(s)); //This works
return Single.fromCallable(new Callable<Integer>() {
@Override
public Integer call() throws NumberFormatException {
return Integer.valueOf(s);
}
});
}
})
.test()
.assertFailure(NumberFormatException.class, 1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import static org.junit.Assert.*;

import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.*;

import org.junit.Test;

Expand Down Expand Up @@ -181,4 +181,22 @@ public MaybeSource<Integer> apply(Integer v) throws Exception {
.test()
.assertResult(1, 2);
}

@Test
public void middleError() {
Observable.fromArray(new String[]{"1","a","2"}).flatMapMaybe(new Function<String, MaybeSource<Integer>>() {
@Override
public MaybeSource<Integer> apply(final String s) throws NumberFormatException {
//return Single.just(Integer.valueOf(s)); //This works
return Maybe.fromCallable(new Callable<Integer>() {
@Override
public Integer call() throws NumberFormatException {
return Integer.valueOf(s);
}
});
}
})
.test()
.assertFailure(NumberFormatException.class, 1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import static org.junit.Assert.*;

import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.*;

import org.junit.Test;

Expand Down Expand Up @@ -168,4 +168,22 @@ public SingleSource<Integer> apply(Integer v) throws Exception {
.test()
.assertResult(1, 2);
}

@Test
public void middleError() {
Observable.fromArray(new String[]{"1","a","2"}).flatMapSingle(new Function<String, SingleSource<Integer>>() {
@Override
public SingleSource<Integer> apply(final String s) throws NumberFormatException {
//return Single.just(Integer.valueOf(s)); //This works
return Single.fromCallable(new Callable<Integer>() {
@Override
public Integer call() throws NumberFormatException {
return Integer.valueOf(s);
}
});
}
})
.test()
.assertFailure(NumberFormatException.class, 1);
}
}