diff --git a/src/main/java/io/reactivex/processors/AsyncProcessor.java b/src/main/java/io/reactivex/processors/AsyncProcessor.java index e360d17eb3..3cce2ee466 100644 --- a/src/main/java/io/reactivex/processors/AsyncProcessor.java +++ b/src/main/java/io/reactivex/processors/AsyncProcessor.java @@ -12,7 +12,6 @@ */ package io.reactivex.processors; -import java.util.Arrays; import java.util.concurrent.atomic.AtomicReference; import org.reactivestreams.*; @@ -63,7 +62,7 @@ * This {@code AsyncProcessor} supports the standard state-peeking methods {@link #hasComplete()}, {@link #hasThrowable()}, * {@link #getThrowable()} and {@link #hasSubscribers()} as well as means to read the very last observed value - * after this {@code AsyncProcessor} has been completed - in a non-blocking and thread-safe - * manner via {@link #hasValue()}, {@link #getValue()}, {@link #getValues()} or {@link #getValues(Object[])}. + * manner via {@link #hasValue()} or {@link #getValue()}. *
*
Backpressure:
*
The {@code AsyncProcessor} honors the backpressure of the downstream {@code Subscriber}s and won't emit @@ -331,46 +330,6 @@ public T getValue() { return subscribers.get() == TERMINATED ? value : null; } - /** - * Returns an Object array containing snapshot all values of this processor. - *

The method is thread-safe. - * @return the array containing the snapshot of all values of this processor - * @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]; - } - - /** - * Returns a typed array containing a snapshot of all values of this processor. - *

The method follows the conventions of Collection.toArray by setting the array element - * after the last value to null (if the capacity permits). - *

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) { - if (array.length != 0) { - array[0] = null; - } - return array; - } - if (array.length == 0) { - array = Arrays.copyOf(array, 1); - } - array[0] = v; - if (array.length != 1) { - array[1] = null; - } - return array; - } - static final class AsyncSubscription extends DeferredScalarSubscription { private static final long serialVersionUID = 5629876084736248016L; diff --git a/src/main/java/io/reactivex/processors/BehaviorProcessor.java b/src/main/java/io/reactivex/processors/BehaviorProcessor.java index a81c51085e..74ef0041eb 100644 --- a/src/main/java/io/reactivex/processors/BehaviorProcessor.java +++ b/src/main/java/io/reactivex/processors/BehaviorProcessor.java @@ -13,7 +13,6 @@ package io.reactivex.processors; -import java.lang.reflect.Array; import java.util.concurrent.atomic.*; import java.util.concurrent.locks.*; @@ -95,8 +94,7 @@ *

* This {@code BehaviorProcessor} supports the standard state-peeking methods {@link #hasComplete()}, {@link #hasThrowable()}, * {@link #getThrowable()} and {@link #hasSubscribers()} as well as means to read the latest observed value - * in a non-blocking and thread-safe manner via {@link #hasValue()}, {@link #getValue()}, - * {@link #getValues()} or {@link #getValues(Object[])}. + * in a non-blocking and thread-safe manner via {@link #hasValue()} or {@link #getValue()}. *

* Note that this processor signals {@code MissingBackpressureException} if a particular {@code Subscriber} is not * ready to receive {@code onNext} events. To avoid this exception being signaled, use {@link #offer(Object)} to only @@ -374,56 +372,6 @@ public T getValue() { return NotificationLite.getValue(o); } - /** - * Returns an Object array containing snapshot all values of the BehaviorProcessor. - *

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; - T[] b = getValues(a); - if (b == EMPTY_ARRAY) { - return new Object[0]; - } - return b; - - } - - /** - * Returns a typed array containing a snapshot of all values of the BehaviorProcessor. - *

The method follows the conventions of Collection.toArray by setting the array element - * after the last value to null (if the capacity permits). - *

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(); - if (o == null || NotificationLite.isComplete(o) || NotificationLite.isError(o)) { - if (array.length != 0) { - array[0] = null; - } - return array; - } - T v = NotificationLite.getValue(o); - if (array.length != 0) { - array[0] = v; - if (array.length != 1) { - array[1] = null; - } - } else { - array = (T[])Array.newInstance(array.getClass().getComponentType(), 1); - array[0] = v; - } - return array; - } - @Override public boolean hasComplete() { Object o = value.get(); diff --git a/src/main/java/io/reactivex/subjects/AsyncSubject.java b/src/main/java/io/reactivex/subjects/AsyncSubject.java index ce9b2dcedb..6bc006393d 100644 --- a/src/main/java/io/reactivex/subjects/AsyncSubject.java +++ b/src/main/java/io/reactivex/subjects/AsyncSubject.java @@ -13,13 +13,10 @@ package io.reactivex.subjects; -import io.reactivex.annotations.Nullable; -import io.reactivex.annotations.NonNull; -import java.util.Arrays; import java.util.concurrent.atomic.AtomicReference; import io.reactivex.Observer; -import io.reactivex.annotations.CheckReturnValue; +import io.reactivex.annotations.*; import io.reactivex.disposables.Disposable; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.observers.DeferredScalarDisposable; @@ -64,7 +61,7 @@ * This {@code AsyncSubject} supports the standard state-peeking methods {@link #hasComplete()}, {@link #hasThrowable()}, * {@link #getThrowable()} and {@link #hasObservers()} as well as means to read the very last observed value - * after this {@code AsyncSubject} has been completed - in a non-blocking and thread-safe - * manner via {@link #hasValue()}, {@link #getValue()}, {@link #getValues()} or {@link #getValues(Object[])}. + * manner via {@link #hasValue()} or {@link #getValue()}. *

*
Scheduler:
*
{@code AsyncSubject} does not operate by default on a particular {@link io.reactivex.Scheduler} and @@ -321,46 +318,6 @@ public T getValue() { return subscribers.get() == TERMINATED ? value : null; } - /** - * Returns an Object array containing snapshot all values of the Subject. - *

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]; - } - - /** - * Returns a typed array containing a snapshot of all values of the Subject. - *

The method follows the conventions of Collection.toArray by setting the array element - * after the last value to null (if the capacity permits). - *

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) { - if (array.length != 0) { - array[0] = null; - } - return array; - } - if (array.length == 0) { - array = Arrays.copyOf(array, 1); - } - array[0] = v; - if (array.length != 1) { - array[1] = null; - } - return array; - } - static final class AsyncDisposable extends DeferredScalarDisposable { private static final long serialVersionUID = 5629876084736248016L; diff --git a/src/main/java/io/reactivex/subjects/BehaviorSubject.java b/src/main/java/io/reactivex/subjects/BehaviorSubject.java index c58cb40779..417ea310b0 100644 --- a/src/main/java/io/reactivex/subjects/BehaviorSubject.java +++ b/src/main/java/io/reactivex/subjects/BehaviorSubject.java @@ -13,14 +13,11 @@ package io.reactivex.subjects; -import io.reactivex.annotations.CheckReturnValue; -import io.reactivex.annotations.Nullable; -import io.reactivex.annotations.NonNull; -import java.lang.reflect.Array; import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.locks.*; import io.reactivex.Observer; +import io.reactivex.annotations.*; import io.reactivex.disposables.Disposable; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.util.*; @@ -97,8 +94,7 @@ *

* This {@code BehaviorSubject} supports the standard state-peeking methods {@link #hasComplete()}, {@link #hasThrowable()}, * {@link #getThrowable()} and {@link #hasObservers()} as well as means to read the latest observed value - * in a non-blocking and thread-safe manner via {@link #hasValue()}, {@link #getValue()}, - * {@link #getValues()} or {@link #getValues(Object[])}. + * in a non-blocking and thread-safe manner via {@link #hasValue()} or {@link #getValue()}. *

*
Scheduler:
*
{@code BehaviorSubject} does not operate by default on a particular {@link io.reactivex.Scheduler} and @@ -153,9 +149,6 @@ */ public final class BehaviorSubject extends Subject { - /** An empty array to avoid allocation in getValues(). */ - private static final Object[] EMPTY_ARRAY = new Object[0]; - final AtomicReference value; final AtomicReference[]> subscribers; @@ -326,56 +319,6 @@ public T getValue() { return NotificationLite.getValue(o); } - /** - * Returns an Object array containing snapshot all values of the Subject. - *

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; - T[] b = getValues(a); - if (b == EMPTY_ARRAY) { - return new Object[0]; - } - return b; - - } - - /** - * Returns a typed array containing a snapshot of all values of the Subject. - *

The method follows the conventions of Collection.toArray by setting the array element - * after the last value to null (if the capacity permits). - *

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(); - if (o == null || NotificationLite.isComplete(o) || NotificationLite.isError(o)) { - if (array.length != 0) { - array[0] = null; - } - return array; - } - T v = NotificationLite.getValue(o); - if (array.length != 0) { - array[0] = v; - if (array.length != 1) { - array[1] = null; - } - } else { - array = (T[])Array.newInstance(array.getClass().getComponentType(), 1); - array[0] = v; - } - return array; - } - @Override public boolean hasComplete() { Object o = value.get(); diff --git a/src/test/java/io/reactivex/processors/SerializedProcessorTest.java b/src/test/java/io/reactivex/processors/SerializedProcessorTest.java index 9d5b51c152..9772d780e0 100644 --- a/src/test/java/io/reactivex/processors/SerializedProcessorTest.java +++ b/src/test/java/io/reactivex/processors/SerializedProcessorTest.java @@ -38,7 +38,6 @@ public void testBasic() { ts.assertValue("hello"); } - @SuppressWarnings("deprecation") @Test public void testAsyncSubjectValueRelay() { AsyncProcessor async = AsyncProcessor.create(); @@ -52,13 +51,8 @@ public void testAsyncSubjectValueRelay() { assertNull(serial.getThrowable()); assertEquals((Integer)1, async.getValue()); assertTrue(async.hasValue()); - assertArrayEquals(new Object[] { 1 }, async.getValues()); - assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[0])); - 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 async = AsyncProcessor.create(); @@ -71,13 +65,8 @@ public void testAsyncSubjectValueEmpty() { assertNull(serial.getThrowable()); assertNull(async.getValue()); assertFalse(async.hasValue()); - assertArrayEquals(new Object[] { }, async.getValues()); - assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0])); - 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 async = AsyncProcessor.create(); @@ -91,10 +80,6 @@ public void testAsyncSubjectValueError() { assertSame(te, serial.getThrowable()); assertNull(async.getValue()); assertFalse(async.hasValue()); - assertArrayEquals(new Object[] { }, async.getValues()); - assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0])); - assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 })); - assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 })); } @Test @@ -135,7 +120,6 @@ public void testPublishSubjectValueError() { assertSame(te, serial.getThrowable()); } - @SuppressWarnings("deprecation") @Test public void testBehaviorSubjectValueRelay() { BehaviorProcessor async = BehaviorProcessor.create(); @@ -149,13 +133,8 @@ public void testBehaviorSubjectValueRelay() { assertNull(serial.getThrowable()); assertNull(async.getValue()); assertFalse(async.hasValue()); - assertArrayEquals(new Object[] { }, async.getValues()); - assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0])); - 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 async = BehaviorProcessor.create(); @@ -168,13 +147,8 @@ public void testBehaviorSubjectValueRelayIncomplete() { assertNull(serial.getThrowable()); assertEquals((Integer)1, async.getValue()); assertTrue(async.hasValue()); - assertArrayEquals(new Object[] { 1 }, async.getValues()); - assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[0])); - 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 async = BehaviorProcessor.create(); @@ -186,13 +160,8 @@ public void testBehaviorSubjectIncompleteEmpty() { assertNull(serial.getThrowable()); assertNull(async.getValue()); assertFalse(async.hasValue()); - assertArrayEquals(new Object[] { }, async.getValues()); - assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0])); - 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 async = BehaviorProcessor.create(); @@ -205,13 +174,8 @@ public void testBehaviorSubjectEmpty() { assertNull(serial.getThrowable()); assertNull(async.getValue()); assertFalse(async.hasValue()); - assertArrayEquals(new Object[] { }, async.getValues()); - assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0])); - 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 async = BehaviorProcessor.create(); @@ -225,10 +189,6 @@ public void testBehaviorSubjectError() { assertSame(te, serial.getThrowable()); assertNull(async.getValue()); assertFalse(async.hasValue()); - assertArrayEquals(new Object[] { }, async.getValues()); - assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0])); - assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 })); - assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 })); } @Test diff --git a/src/test/java/io/reactivex/subjects/SerializedSubjectTest.java b/src/test/java/io/reactivex/subjects/SerializedSubjectTest.java index 8d679b7024..fad8557f2c 100644 --- a/src/test/java/io/reactivex/subjects/SerializedSubjectTest.java +++ b/src/test/java/io/reactivex/subjects/SerializedSubjectTest.java @@ -39,7 +39,6 @@ public void testBasic() { to.assertValue("hello"); } - @SuppressWarnings("deprecation") @Test public void testAsyncSubjectValueRelay() { AsyncSubject async = AsyncSubject.create(); @@ -53,13 +52,8 @@ public void testAsyncSubjectValueRelay() { assertNull(serial.getThrowable()); assertEquals((Integer)1, async.getValue()); assertTrue(async.hasValue()); - assertArrayEquals(new Object[] { 1 }, async.getValues()); - assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[0])); - 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 async = AsyncSubject.create(); @@ -72,13 +66,8 @@ public void testAsyncSubjectValueEmpty() { assertNull(serial.getThrowable()); assertNull(async.getValue()); assertFalse(async.hasValue()); - assertArrayEquals(new Object[] { }, async.getValues()); - assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0])); - 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 async = AsyncSubject.create(); @@ -92,10 +81,6 @@ public void testAsyncSubjectValueError() { assertSame(te, serial.getThrowable()); assertNull(async.getValue()); assertFalse(async.hasValue()); - assertArrayEquals(new Object[] { }, async.getValues()); - assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0])); - assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 })); - assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 })); } @Test @@ -136,7 +121,6 @@ public void testPublishSubjectValueError() { assertSame(te, serial.getThrowable()); } - @SuppressWarnings("deprecation") @Test public void testBehaviorSubjectValueRelay() { BehaviorSubject async = BehaviorSubject.create(); @@ -150,13 +134,8 @@ public void testBehaviorSubjectValueRelay() { assertNull(serial.getThrowable()); assertNull(async.getValue()); assertFalse(async.hasValue()); - assertArrayEquals(new Object[] { }, async.getValues()); - assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0])); - 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 async = BehaviorSubject.create(); @@ -169,13 +148,8 @@ public void testBehaviorSubjectValueRelayIncomplete() { assertNull(serial.getThrowable()); assertEquals((Integer)1, async.getValue()); assertTrue(async.hasValue()); - assertArrayEquals(new Object[] { 1 }, async.getValues()); - assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[0])); - 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 async = BehaviorSubject.create(); @@ -187,13 +161,8 @@ public void testBehaviorSubjectIncompleteEmpty() { assertNull(serial.getThrowable()); assertNull(async.getValue()); assertFalse(async.hasValue()); - assertArrayEquals(new Object[] { }, async.getValues()); - assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0])); - 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 async = BehaviorSubject.create(); @@ -206,13 +175,8 @@ public void testBehaviorSubjectEmpty() { assertNull(serial.getThrowable()); assertNull(async.getValue()); assertFalse(async.hasValue()); - assertArrayEquals(new Object[] { }, async.getValues()); - assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0])); - 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 async = BehaviorSubject.create(); @@ -226,10 +190,6 @@ public void testBehaviorSubjectError() { assertSame(te, serial.getThrowable()); assertNull(async.getValue()); assertFalse(async.hasValue()); - assertArrayEquals(new Object[] { }, async.getValues()); - assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0])); - assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 })); - assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 })); } @Test