@@ -1347,20 +1347,20 @@ public final Completable doOnError(Action1<? super Throwable> onError) {
1347
1347
* @param onSubscribe the consumer called when a CompletableSubscriber subscribes.
1348
1348
* @param onError the consumer called when this emits an onError event
1349
1349
* @param onComplete the runnable called just before when this Completable completes normally
1350
- * @param onAfterComplete the runnable called after this Completable completes normally
1350
+ * @param onAfterTerminate the runnable called after this Completable terminates
1351
1351
* @param onUnsubscribe the runnable called when the child cancels the subscription
1352
1352
* @return the new Completable instance
1353
1353
*/
1354
1354
protected final Completable doOnLifecycle (
1355
1355
final Action1 <? super Subscription > onSubscribe ,
1356
1356
final Action1 <? super Throwable > onError ,
1357
1357
final Action0 onComplete ,
1358
- final Action0 onAfterComplete ,
1358
+ final Action0 onAfterTerminate ,
1359
1359
final Action0 onUnsubscribe ) {
1360
1360
requireNonNull (onSubscribe );
1361
1361
requireNonNull (onError );
1362
1362
requireNonNull (onComplete );
1363
- requireNonNull (onAfterComplete );
1363
+ requireNonNull (onAfterTerminate );
1364
1364
requireNonNull (onUnsubscribe );
1365
1365
return create (new OnSubscribe () {
1366
1366
@ Override
@@ -1379,7 +1379,7 @@ public void onCompleted() {
1379
1379
s .onCompleted ();
1380
1380
1381
1381
try {
1382
- onAfterComplete .call ();
1382
+ onAfterTerminate .call ();
1383
1383
} catch (Throwable e ) {
1384
1384
RxJavaHooks .onError (e );
1385
1385
}
@@ -1394,6 +1394,12 @@ public void onError(Throwable e) {
1394
1394
}
1395
1395
1396
1396
s .onError (e );
1397
+
1398
+ try {
1399
+ onAfterTerminate .call ();
1400
+ } catch (Throwable ex ) {
1401
+ RxJavaHooks .onError (ex );
1402
+ }
1397
1403
}
1398
1404
1399
1405
@ Override
@@ -1455,12 +1461,12 @@ public void call(Throwable e) {
1455
1461
/**
1456
1462
* Returns a Completable instance that calls the given onAfterComplete callback after this
1457
1463
* Completable completes normally.
1458
- * @param onAfterComplete the callback to call after this Completable emits an onComplete event.
1464
+ * @param onAfterTerminate the callback to call after this Completable emits an onCompleted or onError event.
1459
1465
* @return the new Completable instance
1460
1466
* @throws NullPointerException if onAfterComplete is null
1461
1467
*/
1462
- public final Completable doAfterTerminate (Action0 onAfterComplete ) {
1463
- return doOnLifecycle (Actions .empty (), Actions .empty (), Actions .empty (), onAfterComplete , Actions .empty ());
1468
+ public final Completable doAfterTerminate (Action0 onAfterTerminate ) {
1469
+ return doOnLifecycle (Actions .empty (), Actions .empty (), Actions .empty (), onAfterTerminate , Actions .empty ());
1464
1470
}
1465
1471
1466
1472
/**
0 commit comments