Comments (3)
Fix deployed to Maven Central 0.1.30 (should be downloadable there in 10 minutes or so), thanks for the report and diagnosis!
from rxjava2-extras.
It seems that the logic of both retryWhenInstanceOf
and failWhenInstanceOf
are backwards:
// e = the actual error
// cls = the class passed into the retry or fail instance lists
if (e.throwable().getClass().isAssignableFrom(cls)) {
So if the thrown error is assignable from the retry/fail class, then it will work. Otherwise it won't. But you will virtually never actually want that. You should be able to pass a parent class to this list, and any subclass instance that is thrown will then match here.
"Assignable from" means you can assign the right side instance, to the left side class, without explicitly casting.
In other words:
A.class.isAssignableFrom(B.class)
// means this should work correctly:
A a; B b; a = b;
// and the opposite will require a cast:
b = (B) a;
that's because if A is assignable from B, then an A variable can be assigned an instance of B. But if B is not assignable from A, then you can't simply assign it and instead you would have to cast it (which might fail with ClassCastException)
The correct fix is to flip the "isAssignableFrom" operands:
@Override
public Flowable<ErrorAndDuration> apply(ErrorAndDuration e) throws Exception {
if (!exceptionPredicate.test(e.throwable())) {
return Flowable.error(e.throwable());
}
for (Class<? extends Throwable> cls : failExceptions) {
if (cls.isAssignableFrom(e.throwable().getClass())) { // <--- this is flipped
return Flowable.error(e.throwable());
}
}
if (retryExceptions.size() > 0) {
for (Class<? extends Throwable> cls : retryExceptions) {
if (cls.isAssignableFrom(e.throwable().getClass())) { // <--- this is flipped
return Flowable.just(e);
}
}
return Flowable.error(e.throwable());
} else {
return Flowable.just(e);
}
}
from rxjava2-extras.
Thanks for that! I'll knock up a failing unit test and apply your fix. You are very welcome to make a PR if you'd like otherwise I'll do the fix now.
from rxjava2-extras.
Related Issues (17)
- OrderedMerge operator
- Thanks for providing proguard rules
- Some flaky tests HOT 6
- String Flowable to InputStream bridge HOT 3
- Strings.split appends extraneous empty strings
- Feature request: allow RetryWhen to count only consecutive errors HOT 2
- RetryWhen.retryWhenInstanceOf produces java warning
- Android P blacklist HOT 1
- gradle shrink fails for Android gradle project HOT 5
- When do you support RxJava3? HOT 2
- min
- minRequest and maxRequest review please
- rxjava 2.0.6 and 2.0.7 related errors HOT 1
- Observable vs Flowable Support HOT 3
- document Observables/Flowables.cache HOT 2
- Bad interleaving found that causes test failure HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxjava2-extras.