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: deprecate getValues() in Subjects/Processors #5982

Merged
merged 1 commit into from
Apr 30, 2018
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
4 changes: 4 additions & 0 deletions src/main/java/io/reactivex/processors/AsyncProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ public T getValue() {
* Returns an Object array containing snapshot all values of the Subject.
* <p>The method is thread-safe.
* @return the array containing the snapshot of all values of the Subject
* @deprecated in 2.1.14; put the result of {@link #getValue()} into an array manually, will be removed in 3.x
*/
@Deprecated
public Object[] getValues() {
T v = getValue();
return v != null ? new Object[] { v } : new Object[0];
Expand All @@ -267,7 +269,9 @@ public Object[] getValues() {
* <p>The method is thread-safe.
* @param array the target array to copy values into if it fits
* @return the given array if the values fit into it or a new array containing all values
* @deprecated in 2.1.14; put the result of {@link #getValue()} into an array manually, will be removed in 3.x
*/
@Deprecated
public T[] getValues(T[] array) {
T v = getValue();
if (v == null) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/io/reactivex/processors/BehaviorProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,9 @@ public T getValue() {
* Returns an Object array containing snapshot all values of the BehaviorProcessor.
* <p>The method is thread-safe.
* @return the array containing the snapshot of all values of the BehaviorProcessor
* @deprecated in 2.1.14; put the result of {@link #getValue()} into an array manually, will be removed in 3.x
*/
@Deprecated
public Object[] getValues() {
@SuppressWarnings("unchecked")
T[] a = (T[])EMPTY_ARRAY;
Expand All @@ -396,7 +398,9 @@ public Object[] getValues() {
* <p>The method is thread-safe.
* @param array the target array to copy values into if it fits
* @return the given array if the values fit into it or a new array containing all values
* @deprecated in 2.1.14; put the result of {@link #getValue()} into an array manually, will be removed in 3.x
*/
@Deprecated
@SuppressWarnings("unchecked")
public T[] getValues(T[] array) {
Object o = value.get();
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/io/reactivex/subjects/AsyncSubject.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,9 @@ public T getValue() {
* Returns an Object array containing snapshot all values of the Subject.
* <p>The method is thread-safe.
* @return the array containing the snapshot of all values of the Subject
* @deprecated in 2.1.14; put the result of {@link #getValue()} into an array manually, will be removed in 3.x
*/
@Deprecated
public Object[] getValues() {
T v = getValue();
return v != null ? new Object[] { v } : new Object[0];
Expand All @@ -338,7 +340,9 @@ public Object[] getValues() {
* <p>The method is thread-safe.
* @param array the target array to copy values into if it fits
* @return the given array if the values fit into it or a new array containing all values
* @deprecated in 2.1.14; put the result of {@link #getValue()} into an array manually, will be removed in 3.x
*/
@Deprecated
public T[] getValues(T[] array) {
T v = getValue();
if (v == null) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/io/reactivex/subjects/BehaviorSubject.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,9 @@ public T getValue() {
* Returns an Object array containing snapshot all values of the Subject.
* <p>The method is thread-safe.
* @return the array containing the snapshot of all values of the Subject
* @deprecated in 2.1.14; put the result of {@link #getValue()} into an array manually, will be removed in 3.x
*/
@Deprecated
public Object[] getValues() {
@SuppressWarnings("unchecked")
T[] a = (T[])EMPTY_ARRAY;
Expand All @@ -350,7 +352,9 @@ public Object[] getValues() {
* <p>The method is thread-safe.
* @param array the target array to copy values into if it fits
* @return the given array if the values fit into it or a new array containing all values
* @deprecated in 2.1.14; put the result of {@link #getValue()} into an array manually, will be removed in 3.x
*/
@Deprecated
@SuppressWarnings("unchecked")
public T[] getValues(T[] array) {
Object o = value.get();
Expand Down
15 changes: 15 additions & 0 deletions src/test/java/io/reactivex/processors/SerializedProcessorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public void testBasic() {
ts.assertValue("hello");
}

@SuppressWarnings("deprecation")
@Test
public void testAsyncSubjectValueRelay() {
AsyncProcessor<Integer> async = AsyncProcessor.create();
Expand All @@ -56,6 +57,8 @@ public void testAsyncSubjectValueRelay() {
assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
}

@SuppressWarnings("deprecation")
@Test
public void testAsyncSubjectValueEmpty() {
AsyncProcessor<Integer> async = AsyncProcessor.create();
Expand All @@ -73,6 +76,8 @@ public void testAsyncSubjectValueEmpty() {
assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
}

@SuppressWarnings("deprecation")
@Test
public void testAsyncSubjectValueError() {
AsyncProcessor<Integer> async = AsyncProcessor.create();
Expand All @@ -91,6 +96,7 @@ public void testAsyncSubjectValueError() {
assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
}

@Test
public void testPublishSubjectValueRelay() {
PublishProcessor<Integer> async = PublishProcessor.create();
Expand Down Expand Up @@ -128,6 +134,7 @@ public void testPublishSubjectValueError() {
assertSame(te, serial.getThrowable());
}

@SuppressWarnings("deprecation")
@Test
public void testBehaviorSubjectValueRelay() {
BehaviorProcessor<Integer> async = BehaviorProcessor.create();
Expand All @@ -146,6 +153,8 @@ public void testBehaviorSubjectValueRelay() {
assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
}

@SuppressWarnings("deprecation")
@Test
public void testBehaviorSubjectValueRelayIncomplete() {
BehaviorProcessor<Integer> async = BehaviorProcessor.create();
Expand All @@ -163,6 +172,8 @@ public void testBehaviorSubjectValueRelayIncomplete() {
assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
}

@SuppressWarnings("deprecation")
@Test
public void testBehaviorSubjectIncompleteEmpty() {
BehaviorProcessor<Integer> async = BehaviorProcessor.create();
Expand All @@ -179,6 +190,8 @@ public void testBehaviorSubjectIncompleteEmpty() {
assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
}

@SuppressWarnings("deprecation")
@Test
public void testBehaviorSubjectEmpty() {
BehaviorProcessor<Integer> async = BehaviorProcessor.create();
Expand All @@ -196,6 +209,8 @@ public void testBehaviorSubjectEmpty() {
assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
}

@SuppressWarnings("deprecation")
@Test
public void testBehaviorSubjectError() {
BehaviorProcessor<Integer> async = BehaviorProcessor.create();
Expand Down
16 changes: 16 additions & 0 deletions src/test/java/io/reactivex/subjects/SerializedSubjectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public void testBasic() {
to.assertValue("hello");
}

@SuppressWarnings("deprecation")
@Test
public void testAsyncSubjectValueRelay() {
AsyncSubject<Integer> async = AsyncSubject.create();
Expand All @@ -57,6 +58,8 @@ public void testAsyncSubjectValueRelay() {
assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
}

@SuppressWarnings("deprecation")
@Test
public void testAsyncSubjectValueEmpty() {
AsyncSubject<Integer> async = AsyncSubject.create();
Expand All @@ -74,6 +77,8 @@ public void testAsyncSubjectValueEmpty() {
assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
}

@SuppressWarnings("deprecation")
@Test
public void testAsyncSubjectValueError() {
AsyncSubject<Integer> async = AsyncSubject.create();
Expand All @@ -92,6 +97,7 @@ public void testAsyncSubjectValueError() {
assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
}

@Test
public void testPublishSubjectValueRelay() {
PublishSubject<Integer> async = PublishSubject.create();
Expand Down Expand Up @@ -129,6 +135,7 @@ public void testPublishSubjectValueError() {
assertSame(te, serial.getThrowable());
}

@SuppressWarnings("deprecation")
@Test
public void testBehaviorSubjectValueRelay() {
BehaviorSubject<Integer> async = BehaviorSubject.create();
Expand All @@ -147,6 +154,8 @@ public void testBehaviorSubjectValueRelay() {
assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
}

@SuppressWarnings("deprecation")
@Test
public void testBehaviorSubjectValueRelayIncomplete() {
BehaviorSubject<Integer> async = BehaviorSubject.create();
Expand All @@ -164,6 +173,8 @@ public void testBehaviorSubjectValueRelayIncomplete() {
assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
}

@SuppressWarnings("deprecation")
@Test
public void testBehaviorSubjectIncompleteEmpty() {
BehaviorSubject<Integer> async = BehaviorSubject.create();
Expand All @@ -180,6 +191,8 @@ public void testBehaviorSubjectIncompleteEmpty() {
assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
}

@SuppressWarnings("deprecation")
@Test
public void testBehaviorSubjectEmpty() {
BehaviorSubject<Integer> async = BehaviorSubject.create();
Expand All @@ -197,6 +210,8 @@ public void testBehaviorSubjectEmpty() {
assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
}

@SuppressWarnings("deprecation")
@Test
public void testBehaviorSubjectError() {
BehaviorSubject<Integer> async = BehaviorSubject.create();
Expand Down Expand Up @@ -234,6 +249,7 @@ public void testReplaySubjectValueRelay() {
assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
}

@Test
public void testReplaySubjectValueRelayIncomplete() {
ReplaySubject<Integer> async = ReplaySubject.create();
Expand Down