Skip to content

Commit 4ae4a40

Browse files
authored
1.2 preparation cleanup and Experimental/Beta/Deprecated adjustments (#4549)
1 parent ff16f76 commit 4ae4a40

File tree

90 files changed

+538
-1123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+538
-1123
lines changed

src/main/java/rx/AsyncEmitter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* <p>
2626
* The onNext, onError and onCompleted methods should be called
2727
* in a sequential manner, just like the Observer's methods. The
28-
* other methods are threadsafe.
28+
* other methods are thread-safe.
2929
*
3030
* @param <T> the value type to emit
3131
* @since (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
@@ -48,7 +48,7 @@ public interface AsyncEmitter<T> extends Observer<T> {
4848
void setCancellation(Cancellable c);
4949
/**
5050
* The current outstanding request amount.
51-
* <p>This method it threadsafe.
51+
* <p>This method it thread-safe.
5252
* @return the current outstanding request amount
5353
*/
5454
long requested();
@@ -81,7 +81,7 @@ enum BackpressureMode {
8181
*/
8282
ERROR,
8383
/**
84-
* Buffers (unbounded) all onNext calls until the dowsntream can consume them.
84+
* Buffers (unbounded) all onNext calls until the downstream can consume them.
8585
*/
8686
BUFFER,
8787
/**

src/main/java/rx/BackpressureOverflow.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
*/
1616
package rx;
1717

18-
import rx.annotations.Experimental;
18+
import rx.annotations.Beta;
1919
import rx.exceptions.MissingBackpressureException;
2020

2121
/**
2222
* Generic strategy and default implementations to deal with backpressure buffer overflows.
23+
*
24+
* @since (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
2325
*/
24-
@Experimental
26+
@Beta
2527
public final class BackpressureOverflow {
2628

2729
/**
@@ -55,7 +57,7 @@ public interface Strategy {
5557
* drop the item currently causing backpressure.
5658
*
5759
* @return true to request drop of the oldest item, false to drop the newest.
58-
* @throws MissingBackpressureException
60+
* @throws MissingBackpressureException if the strategy should signal MissingBackpressureException
5961
*/
6062
boolean mayAttemptDrop() throws MissingBackpressureException;
6163
}

src/main/java/rx/Completable.java

Lines changed: 7 additions & 206 deletions
Original file line numberDiff line numberDiff line change
@@ -20,68 +20,35 @@
2020
import java.util.concurrent.*;
2121
import java.util.concurrent.atomic.AtomicBoolean;
2222

23-
import rx.annotations.Experimental;
23+
import rx.annotations.*;
2424
import rx.exceptions.*;
2525
import rx.functions.*;
2626
import rx.internal.operators.*;
2727
import rx.internal.util.*;
2828
import rx.observers.*;
29-
import rx.plugins.*;
29+
import rx.plugins.RxJavaHooks;
3030
import rx.schedulers.Schedulers;
3131
import rx.subscriptions.*;
3232

3333
/**
3434
* Represents a deferred computation without any value but only indication for completion or exception.
3535
*
3636
* The class follows a similar event pattern as Reactive-Streams: onSubscribe (onError|onComplete)?
37+
*
38+
* @since (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
3739
*/
38-
@Experimental
40+
@Beta
3941
public class Completable {
4042
/** The actual subscription action. */
4143
private final OnSubscribe onSubscribe;
4244

43-
/**
44-
* @deprecated Use {@link OnSubscribe} instead.
45-
*/
46-
@Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
47-
public interface CompletableOnSubscribe extends Action1<CompletableSubscriber> {
48-
49-
}
50-
51-
private static OnSubscribe fromOldOnSubscribe(final CompletableOnSubscribe onSubscribe) {
52-
return new OnSubscribe() {
53-
@Override
54-
public void call(final rx.CompletableSubscriber s) {
55-
onSubscribe.call(toOldSubscriber(s));
56-
}
57-
};
58-
}
59-
6045
/**
6146
* Callback used for building deferred computations that takes a CompletableSubscriber.
6247
*/
6348
public interface OnSubscribe extends Action1<rx.CompletableSubscriber> {
6449

6550
}
6651

67-
/**
68-
* @deprecated Use {@link Operator} instead.
69-
*/
70-
@Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
71-
public interface CompletableOperator extends Func1<CompletableSubscriber, CompletableSubscriber> {
72-
73-
}
74-
75-
private static Operator fromOldOperator(final CompletableOperator operator) {
76-
requireNonNull(operator);
77-
return new Operator() {
78-
@Override
79-
public rx.CompletableSubscriber call(final rx.CompletableSubscriber subscriber) {
80-
return fromOldSubscriber(operator.call(toOldSubscriber(subscriber)));
81-
}
82-
};
83-
}
84-
8552
/**
8653
* Convenience interface and callback used by the lift operator that given a child CompletableSubscriber,
8754
* return a parent CompletableSubscriber that does any kind of lifecycle-related transformations.
@@ -90,78 +57,6 @@ public interface Operator extends Func1<rx.CompletableSubscriber, rx.Completable
9057

9158
}
9259

93-
/**
94-
* @deprecated Use {@link rx.CompletableSubscriber} instead.
95-
*/
96-
@Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
97-
public interface CompletableSubscriber {
98-
/**
99-
* Called once the deferred computation completes normally.
100-
*/
101-
void onCompleted();
102-
103-
/**
104-
* Called once if the deferred computation 'throws' an exception.
105-
* @param e the exception, not null.
106-
*/
107-
void onError(Throwable e);
108-
109-
/**
110-
* Called once by the Completable to set a Subscription on this instance which
111-
* then can be used to cancel the subscription at any time.
112-
* @param d the Subscription instance to call dispose on for cancellation, not null
113-
*/
114-
void onSubscribe(Subscription d);
115-
}
116-
117-
static rx.CompletableSubscriber fromOldSubscriber(final CompletableSubscriber subscriber) {
118-
requireNonNull(subscriber);
119-
return new rx.CompletableSubscriber() {
120-
@Override
121-
public void onCompleted() {
122-
subscriber.onCompleted();
123-
}
124-
125-
@Override
126-
public void onError(Throwable e) {
127-
subscriber.onError(e);
128-
}
129-
130-
@Override
131-
public void onSubscribe(Subscription d) {
132-
subscriber.onSubscribe(d);
133-
}
134-
};
135-
}
136-
137-
static CompletableSubscriber toOldSubscriber(final rx.CompletableSubscriber subscriber) {
138-
requireNonNull(subscriber);
139-
return new CompletableSubscriber() {
140-
@Override
141-
public void onCompleted() {
142-
subscriber.onCompleted();
143-
}
144-
145-
@Override
146-
public void onError(Throwable e) {
147-
subscriber.onError(e);
148-
}
149-
150-
@Override
151-
public void onSubscribe(Subscription d) {
152-
subscriber.onSubscribe(d);
153-
}
154-
};
155-
}
156-
157-
/**
158-
* @deprecated Use {@link Transformer} instead.
159-
*/
160-
@Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
161-
public interface CompletableTransformer extends Transformer {
162-
163-
}
164-
16560
/**
16661
* Convenience interface and callback used by the compose operator to turn a Completable into another
16762
* Completable fluently.
@@ -456,17 +351,6 @@ public static Completable concat(Observable<? extends Completable> sources, int
456351
return create(new CompletableOnSubscribeConcat(sources, prefetch));
457352
}
458353

459-
/**
460-
* Constructs a Completable instance by wrapping the given old onSubscribe callback.
461-
* @param onSubscribe the old CompletableOnSubscribe instance to wrap
462-
* @return a Completable instance
463-
* @deprecated Use {@link #create(OnSubscribe)}.
464-
*/
465-
@Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
466-
public static Completable create(CompletableOnSubscribe onSubscribe) {
467-
return create(fromOldOnSubscribe(onSubscribe));
468-
}
469-
470354
/**
471355
* Constructs a Completable instance by wrapping the given onSubscribe callback.
472356
* @param onSubscribe the callback which will receive the CompletableSubscriber instances
@@ -1117,14 +1001,6 @@ protected Completable(OnSubscribe onSubscribe) {
11171001
this.onSubscribe = RxJavaHooks.onCreate(onSubscribe);
11181002
}
11191003

1120-
/**
1121-
* @deprecated Use {@link #Completable(OnSubscribe)}.
1122-
*/
1123-
@Deprecated // TODO Remove constructor after 1.2.0 release. It was never a stable API. Provided only for migration.
1124-
protected Completable(CompletableOnSubscribe onSubscribe) {
1125-
this(fromOldOnSubscribe(onSubscribe));
1126-
}
1127-
11281004
/**
11291005
* Constructs a Completable instance with the given onSubscribe callback without calling the onCreate
11301006
* hook.
@@ -1136,19 +1012,6 @@ protected Completable(OnSubscribe onSubscribe, boolean useHook) {
11361012
this.onSubscribe = useHook ? RxJavaHooks.onCreate(onSubscribe) : onSubscribe;
11371013
}
11381014

1139-
/**
1140-
* Constructs a Completable instance with the given onSubscribe callback without calling the onCreate
1141-
* hook.
1142-
* @param onSubscribe the callback that will receive CompletableSubscribers when they subscribe,
1143-
* not null (not verified)
1144-
* @param useHook if false, RxJavaHooks.onCreate won't be called
1145-
* @deprecated Use {@link #Completable(OnSubscribe, boolean)}.
1146-
*/
1147-
@Deprecated // TODO Remove constructor after 1.2.0 release. It was never a stable API. Provided only for migration.
1148-
protected Completable(CompletableOnSubscribe onSubscribe, boolean useHook) {
1149-
this(fromOldOnSubscribe(onSubscribe), useHook);
1150-
}
1151-
11521015
/**
11531016
* Returns a Completable that emits the a terminated event of either this Completable
11541017
* or the other Completable whichever fires first.
@@ -1422,17 +1285,6 @@ public void onSubscribe(Subscription d) {
14221285
});
14231286
}
14241287

1425-
/**
1426-
* Returns a Completable which calls the given onComplete callback if this Completable completes.
1427-
* @param onComplete the callback to call when this emits an onComplete event
1428-
* @return the new Completable instance
1429-
* @throws NullPointerException if onComplete is null
1430-
* @deprecated Use {@link #doOnCompleted(Action0)} instead.
1431-
*/
1432-
@Deprecated public final Completable doOnComplete(Action0 onComplete) {
1433-
return doOnCompleted(onComplete);
1434-
}
1435-
14361288
/**
14371289
* Returns a Completable which calls the given onCompleted callback if this Completable completes.
14381290
* @param onCompleted the callback to call when this emits an onComplete event
@@ -1599,34 +1451,6 @@ public void call(Throwable e) {
15991451
}, onTerminate, Actions.empty(), Actions.empty());
16001452
}
16011453

1602-
/**
1603-
* Returns a completable that first runs this Completable
1604-
* and then the other completable.
1605-
* <p>
1606-
* This is an alias for {@link #concatWith(Completable)}.
1607-
* @param other the other Completable, not null
1608-
* @return the new Completable instance
1609-
* @throws NullPointerException if other is null
1610-
* @deprecated Use {@link #andThen(rx.Completable)} instead.
1611-
*/
1612-
@Deprecated
1613-
public final Completable endWith(Completable other) {
1614-
return andThen(other);
1615-
}
1616-
1617-
/**
1618-
* Returns an Observable that first runs this Completable instance and
1619-
* resumes with the given next Observable.
1620-
* @param <T> the value type of the next Observable
1621-
* @param next the next Observable to continue
1622-
* @return the new Observable instance
1623-
* @deprecated Use {@link #andThen(rx.Observable)} instead.
1624-
*/
1625-
@Deprecated
1626-
public final <T> Observable<T> endWith(Observable<T> next) {
1627-
return andThen(next);
1628-
}
1629-
16301454
/**
16311455
* Returns a Completable instance that calls the given onAfterComplete callback after this
16321456
* Completable completes normally.
@@ -1730,18 +1554,6 @@ public void onSubscribe(Subscription d) {
17301554
return null;
17311555
}
17321556

1733-
/**
1734-
* Lifts a CompletableSubscriber transformation into the chain of Completables.
1735-
* @param onLift the lifting function that transforms the child subscriber with a parent subscriber.
1736-
* @return the new Completable instance
1737-
* @throws NullPointerException if onLift is null
1738-
* @deprecated Use {@link #lift(Operator)}.
1739-
*/
1740-
@Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
1741-
public final Completable lift(CompletableOperator onLift) {
1742-
return lift(fromOldOperator(onLift));
1743-
}
1744-
17451557
/**
17461558
* Lifts a CompletableSubscriber transformation into the chain of Completables.
17471559
* @param onLift the lifting function that transforms the child subscriber with a parent subscriber.
@@ -2200,22 +2012,11 @@ public void onSubscribe(Subscription d) {
22002012
return mad;
22012013
}
22022014

2203-
private static void deliverUncaughtException(Throwable e) {
2015+
static void deliverUncaughtException(Throwable e) {
22042016
Thread thread = Thread.currentThread();
22052017
thread.getUncaughtExceptionHandler().uncaughtException(thread, e);
22062018
}
22072019

2208-
/**
2209-
* Subscribes the given CompletableSubscriber to this Completable instance.
2210-
* @param s the CompletableSubscriber, not null
2211-
* @throws NullPointerException if s is null
2212-
* @deprecated Use {@link #unsafeSubscribe(rx.CompletableSubscriber)}.
2213-
*/
2214-
@Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
2215-
public final void unsafeSubscribe(CompletableSubscriber s) {
2216-
unsafeSubscribe(fromOldSubscriber(s));
2217-
}
2218-
22192020
/**
22202021
* Subscribes the given CompletableSubscriber to this Completable instance.
22212022
* @param s the CompletableSubscriber, not null
@@ -2268,7 +2069,7 @@ public final <T> void unsafeSubscribe(final Subscriber<T> s) {
22682069
* @param callOnStart if true, the Subscriber.onStart will be called
22692070
* @throws NullPointerException if s is null
22702071
*/
2271-
private final <T> void unsafeSubscribe(final Subscriber<T> s, boolean callOnStart) {
2072+
private <T> void unsafeSubscribe(final Subscriber<T> s, boolean callOnStart) {
22722073
requireNonNull(s);
22732074
try {
22742075
if (callOnStart) {

src/main/java/rx/Notification.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static <T> Notification<T> createOnCompleted() {
6666
* Creates and returns a {@code Notification} of variety {@code Kind.OnCompleted}.
6767
*
6868
* @param <T> the actual value type held by the Notification
69-
* @param type
69+
* @param type the type token to help with type inference of {@code <T>}
7070
* @deprecated this method does the same as {@link #createOnCompleted()} and does not use the passed in type hence it's useless.
7171
* @return an {@code OnCompleted} variety of {@code Notification}
7272
*/
@@ -217,14 +217,7 @@ public boolean equals(Object obj) {
217217
}
218218

219219
Notification<?> notification = (Notification<?>) obj;
220-
if (notification.getKind() != getKind()) {
221-
return false;
222-
}
223-
224-
if (!(value == notification.value || (value != null && value.equals(notification.value)))) {
225-
return false;
226-
}
220+
return notification.getKind() == getKind() && (value == notification.value || (value != null && value.equals(notification.value))) && (throwable == notification.throwable || (throwable != null && throwable.equals(notification.throwable)));
227221

228-
return (throwable == notification.throwable || (throwable != null && throwable.equals(notification.throwable)));
229222
}
230223
}

0 commit comments

Comments
 (0)