Skip to content

Commit 70f9a83

Browse files
authored
2.x: deprecate getValues() in Subjects/Processors (#5982)
1 parent d07dfa1 commit 70f9a83

File tree

6 files changed

+47
-0
lines changed

6 files changed

+47
-0
lines changed

src/main/java/io/reactivex/processors/AsyncProcessor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,9 @@ public T getValue() {
254254
* Returns an Object array containing snapshot all values of the Subject.
255255
* <p>The method is thread-safe.
256256
* @return the array containing the snapshot of all values of the Subject
257+
* @deprecated in 2.1.14; put the result of {@link #getValue()} into an array manually, will be removed in 3.x
257258
*/
259+
@Deprecated
258260
public Object[] getValues() {
259261
T v = getValue();
260262
return v != null ? new Object[] { v } : new Object[0];
@@ -267,7 +269,9 @@ public Object[] getValues() {
267269
* <p>The method is thread-safe.
268270
* @param array the target array to copy values into if it fits
269271
* @return the given array if the values fit into it or a new array containing all values
272+
* @deprecated in 2.1.14; put the result of {@link #getValue()} into an array manually, will be removed in 3.x
270273
*/
274+
@Deprecated
271275
public T[] getValues(T[] array) {
272276
T v = getValue();
273277
if (v == null) {

src/main/java/io/reactivex/processors/BehaviorProcessor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,9 @@ public T getValue() {
377377
* Returns an Object array containing snapshot all values of the BehaviorProcessor.
378378
* <p>The method is thread-safe.
379379
* @return the array containing the snapshot of all values of the BehaviorProcessor
380+
* @deprecated in 2.1.14; put the result of {@link #getValue()} into an array manually, will be removed in 3.x
380381
*/
382+
@Deprecated
381383
public Object[] getValues() {
382384
@SuppressWarnings("unchecked")
383385
T[] a = (T[])EMPTY_ARRAY;
@@ -396,7 +398,9 @@ public Object[] getValues() {
396398
* <p>The method is thread-safe.
397399
* @param array the target array to copy values into if it fits
398400
* @return the given array if the values fit into it or a new array containing all values
401+
* @deprecated in 2.1.14; put the result of {@link #getValue()} into an array manually, will be removed in 3.x
399402
*/
403+
@Deprecated
400404
@SuppressWarnings("unchecked")
401405
public T[] getValues(T[] array) {
402406
Object o = value.get();

src/main/java/io/reactivex/subjects/AsyncSubject.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,9 @@ public T getValue() {
325325
* Returns an Object array containing snapshot all values of the Subject.
326326
* <p>The method is thread-safe.
327327
* @return the array containing the snapshot of all values of the Subject
328+
* @deprecated in 2.1.14; put the result of {@link #getValue()} into an array manually, will be removed in 3.x
328329
*/
330+
@Deprecated
329331
public Object[] getValues() {
330332
T v = getValue();
331333
return v != null ? new Object[] { v } : new Object[0];
@@ -338,7 +340,9 @@ public Object[] getValues() {
338340
* <p>The method is thread-safe.
339341
* @param array the target array to copy values into if it fits
340342
* @return the given array if the values fit into it or a new array containing all values
343+
* @deprecated in 2.1.14; put the result of {@link #getValue()} into an array manually, will be removed in 3.x
341344
*/
345+
@Deprecated
342346
public T[] getValues(T[] array) {
343347
T v = getValue();
344348
if (v == null) {

src/main/java/io/reactivex/subjects/BehaviorSubject.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,9 @@ public T getValue() {
331331
* Returns an Object array containing snapshot all values of the Subject.
332332
* <p>The method is thread-safe.
333333
* @return the array containing the snapshot of all values of the Subject
334+
* @deprecated in 2.1.14; put the result of {@link #getValue()} into an array manually, will be removed in 3.x
334335
*/
336+
@Deprecated
335337
public Object[] getValues() {
336338
@SuppressWarnings("unchecked")
337339
T[] a = (T[])EMPTY_ARRAY;
@@ -350,7 +352,9 @@ public Object[] getValues() {
350352
* <p>The method is thread-safe.
351353
* @param array the target array to copy values into if it fits
352354
* @return the given array if the values fit into it or a new array containing all values
355+
* @deprecated in 2.1.14; put the result of {@link #getValue()} into an array manually, will be removed in 3.x
353356
*/
357+
@Deprecated
354358
@SuppressWarnings("unchecked")
355359
public T[] getValues(T[] array) {
356360
Object o = value.get();

src/test/java/io/reactivex/processors/SerializedProcessorTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public void testBasic() {
3838
ts.assertValue("hello");
3939
}
4040

41+
@SuppressWarnings("deprecation")
4142
@Test
4243
public void testAsyncSubjectValueRelay() {
4344
AsyncProcessor<Integer> async = AsyncProcessor.create();
@@ -56,6 +57,8 @@ public void testAsyncSubjectValueRelay() {
5657
assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
5758
assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
5859
}
60+
61+
@SuppressWarnings("deprecation")
5962
@Test
6063
public void testAsyncSubjectValueEmpty() {
6164
AsyncProcessor<Integer> async = AsyncProcessor.create();
@@ -73,6 +76,8 @@ public void testAsyncSubjectValueEmpty() {
7376
assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
7477
assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
7578
}
79+
80+
@SuppressWarnings("deprecation")
7681
@Test
7782
public void testAsyncSubjectValueError() {
7883
AsyncProcessor<Integer> async = AsyncProcessor.create();
@@ -91,6 +96,7 @@ public void testAsyncSubjectValueError() {
9196
assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
9297
assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
9398
}
99+
94100
@Test
95101
public void testPublishSubjectValueRelay() {
96102
PublishProcessor<Integer> async = PublishProcessor.create();
@@ -128,6 +134,7 @@ public void testPublishSubjectValueError() {
128134
assertSame(te, serial.getThrowable());
129135
}
130136

137+
@SuppressWarnings("deprecation")
131138
@Test
132139
public void testBehaviorSubjectValueRelay() {
133140
BehaviorProcessor<Integer> async = BehaviorProcessor.create();
@@ -146,6 +153,8 @@ public void testBehaviorSubjectValueRelay() {
146153
assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
147154
assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
148155
}
156+
157+
@SuppressWarnings("deprecation")
149158
@Test
150159
public void testBehaviorSubjectValueRelayIncomplete() {
151160
BehaviorProcessor<Integer> async = BehaviorProcessor.create();
@@ -163,6 +172,8 @@ public void testBehaviorSubjectValueRelayIncomplete() {
163172
assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
164173
assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
165174
}
175+
176+
@SuppressWarnings("deprecation")
166177
@Test
167178
public void testBehaviorSubjectIncompleteEmpty() {
168179
BehaviorProcessor<Integer> async = BehaviorProcessor.create();
@@ -179,6 +190,8 @@ public void testBehaviorSubjectIncompleteEmpty() {
179190
assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
180191
assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
181192
}
193+
194+
@SuppressWarnings("deprecation")
182195
@Test
183196
public void testBehaviorSubjectEmpty() {
184197
BehaviorProcessor<Integer> async = BehaviorProcessor.create();
@@ -196,6 +209,8 @@ public void testBehaviorSubjectEmpty() {
196209
assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
197210
assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
198211
}
212+
213+
@SuppressWarnings("deprecation")
199214
@Test
200215
public void testBehaviorSubjectError() {
201216
BehaviorProcessor<Integer> async = BehaviorProcessor.create();

src/test/java/io/reactivex/subjects/SerializedSubjectTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public void testBasic() {
3939
to.assertValue("hello");
4040
}
4141

42+
@SuppressWarnings("deprecation")
4243
@Test
4344
public void testAsyncSubjectValueRelay() {
4445
AsyncSubject<Integer> async = AsyncSubject.create();
@@ -57,6 +58,8 @@ public void testAsyncSubjectValueRelay() {
5758
assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
5859
assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
5960
}
61+
62+
@SuppressWarnings("deprecation")
6063
@Test
6164
public void testAsyncSubjectValueEmpty() {
6265
AsyncSubject<Integer> async = AsyncSubject.create();
@@ -74,6 +77,8 @@ public void testAsyncSubjectValueEmpty() {
7477
assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
7578
assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
7679
}
80+
81+
@SuppressWarnings("deprecation")
7782
@Test
7883
public void testAsyncSubjectValueError() {
7984
AsyncSubject<Integer> async = AsyncSubject.create();
@@ -92,6 +97,7 @@ public void testAsyncSubjectValueError() {
9297
assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
9398
assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
9499
}
100+
95101
@Test
96102
public void testPublishSubjectValueRelay() {
97103
PublishSubject<Integer> async = PublishSubject.create();
@@ -129,6 +135,7 @@ public void testPublishSubjectValueError() {
129135
assertSame(te, serial.getThrowable());
130136
}
131137

138+
@SuppressWarnings("deprecation")
132139
@Test
133140
public void testBehaviorSubjectValueRelay() {
134141
BehaviorSubject<Integer> async = BehaviorSubject.create();
@@ -147,6 +154,8 @@ public void testBehaviorSubjectValueRelay() {
147154
assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
148155
assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
149156
}
157+
158+
@SuppressWarnings("deprecation")
150159
@Test
151160
public void testBehaviorSubjectValueRelayIncomplete() {
152161
BehaviorSubject<Integer> async = BehaviorSubject.create();
@@ -164,6 +173,8 @@ public void testBehaviorSubjectValueRelayIncomplete() {
164173
assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
165174
assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
166175
}
176+
177+
@SuppressWarnings("deprecation")
167178
@Test
168179
public void testBehaviorSubjectIncompleteEmpty() {
169180
BehaviorSubject<Integer> async = BehaviorSubject.create();
@@ -180,6 +191,8 @@ public void testBehaviorSubjectIncompleteEmpty() {
180191
assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
181192
assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
182193
}
194+
195+
@SuppressWarnings("deprecation")
183196
@Test
184197
public void testBehaviorSubjectEmpty() {
185198
BehaviorSubject<Integer> async = BehaviorSubject.create();
@@ -197,6 +210,8 @@ public void testBehaviorSubjectEmpty() {
197210
assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
198211
assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
199212
}
213+
214+
@SuppressWarnings("deprecation")
200215
@Test
201216
public void testBehaviorSubjectError() {
202217
BehaviorSubject<Integer> async = BehaviorSubject.create();
@@ -234,6 +249,7 @@ public void testReplaySubjectValueRelay() {
234249
assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
235250
assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
236251
}
252+
237253
@Test
238254
public void testReplaySubjectValueRelayIncomplete() {
239255
ReplaySubject<Integer> async = ReplaySubject.create();

0 commit comments

Comments
 (0)