Skip to content

Commit 10e5b12

Browse files
Merge pull request #1436 from gliptak/genericswarnings
Correct warnings
2 parents 0b9c1fb + 583412e commit 10e5b12

File tree

5 files changed

+28
-38
lines changed

5 files changed

+28
-38
lines changed

rxjava-core/src/main/java/rx/internal/operators/OperatorMerge.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public void onStart() {
148148
@Override
149149
public void onNext(Observable<? extends T> t) {
150150
if (t instanceof ScalarSynchronousObservable) {
151-
handleScalarSynchronousObservable(t);
151+
handleScalarSynchronousObservable((ScalarSynchronousObservable)t);
152152
} else {
153153
if (t == null || isUnsubscribed()) {
154154
return;
@@ -191,7 +191,7 @@ private void handleNewSource(Observable<? extends T> t) {
191191
request(1);
192192
}
193193

194-
private void handleScalarSynchronousObservable(Observable<? extends T> t) {
194+
private void handleScalarSynchronousObservable(ScalarSynchronousObservable<? extends T> t) {
195195
// fast-path for scalar, synchronous values such as Observable.from(int)
196196
/**
197197
* Without this optimization:
@@ -217,8 +217,8 @@ private void handleScalarSynchronousObservable(Observable<? extends T> t) {
217217
}
218218
}
219219

220-
private void handleScalarSynchronousObservableWithoutRequestLimits(Observable<? extends T> t) {
221-
T value = ((ScalarSynchronousObservable<T>) t).get();
220+
private void handleScalarSynchronousObservableWithoutRequestLimits(ScalarSynchronousObservable<? extends T> t) {
221+
T value = t.get();
222222
if (getEmitLock()) {
223223
try {
224224
actual.onNext(value);
@@ -240,15 +240,15 @@ private void handleScalarSynchronousObservableWithoutRequestLimits(Observable<?
240240
}
241241
}
242242

243-
private void handleScalarSynchronousObservableWithRequestLimits(Observable<? extends T> t) {
243+
private void handleScalarSynchronousObservableWithRequestLimits(ScalarSynchronousObservable<? extends T> t) {
244244
if (getEmitLock()) {
245245
boolean emitted = false;
246246
try {
247247
long r = mergeProducer.requested;
248248
if (r > 0) {
249249
emitted = true;
250-
actual.onNext(((ScalarSynchronousObservable<T>) t).get());
251-
mergeProducer.REQUESTED.decrementAndGet(mergeProducer);
250+
actual.onNext(t.get());
251+
MergeProducer.REQUESTED.decrementAndGet(mergeProducer);
252252
// we handle this Observable without ever incrementing the wip or touching other machinery so just return here
253253
return;
254254
}
@@ -266,7 +266,7 @@ private void handleScalarSynchronousObservableWithRequestLimits(Observable<? ext
266266
// enqueue the values for later delivery
267267
initScalarValueQueueIfNeeded();
268268
try {
269-
scalarValueQueue.onNext(((ScalarSynchronousObservable<T>) t).get());
269+
scalarValueQueue.onNext(t.get());
270270
} catch (MissingBackpressureException e) {
271271
onError(e);
272272
}
@@ -359,7 +359,7 @@ private int drainScalarValueQueue() {
359359
}
360360
}
361361
// decrement the number we emitted from outstanding requests
362-
mergeProducer.REQUESTED.getAndAdd(mergeProducer, -emittedWhileDraining);
362+
MergeProducer.REQUESTED.getAndAdd(mergeProducer, -emittedWhileDraining);
363363
}
364364
return emittedWhileDraining;
365365
}
@@ -617,7 +617,7 @@ private void emit(T t, boolean complete) {
617617
onError(OnErrorThrowable.addValueAsLastCause(e, t));
618618
}
619619
emitted++;
620-
producer.REQUESTED.decrementAndGet(producer);
620+
MergeProducer.REQUESTED.decrementAndGet(producer);
621621
}
622622
} else {
623623
// no requests available, so enqueue it
@@ -709,7 +709,7 @@ private int drainRequested() {
709709
}
710710

711711
// decrement the number we emitted from outstanding requests
712-
producer.REQUESTED.getAndAdd(producer, -emitted);
712+
MergeProducer.REQUESTED.getAndAdd(producer, -emitted);
713713
return emitted;
714714
}
715715

rxjava-core/src/main/java/rx/internal/util/RxRingBuffer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public static RxRingBuffer getSpmcInstance() {
173173

174174
@Override
175175
protected SpscArrayQueue<Object> createObject() {
176-
return new SpscArrayQueue(SIZE);
176+
return new SpscArrayQueue<Object>(SIZE);
177177
}
178178

179179
};
@@ -182,12 +182,12 @@ protected SpscArrayQueue<Object> createObject() {
182182

183183
@Override
184184
protected SpmcArrayQueue<Object> createObject() {
185-
return new SpmcArrayQueue(SIZE);
185+
return new SpmcArrayQueue<Object>(SIZE);
186186
}
187187

188188
};
189189

190-
private RxRingBuffer(Queue queue, int size) {
190+
private RxRingBuffer(Queue<Object> queue, int size) {
191191
this.queue = queue;
192192
this.pool = null;
193193
this.size = size;
@@ -201,7 +201,7 @@ private RxRingBuffer(ObjectPool<Queue<Object>> pool, int size) {
201201

202202
public void release() {
203203
if (pool != null) {
204-
Queue q = queue;
204+
Queue<Object> q = queue;
205205
q.clear();
206206
queue = null;
207207
pool.returnObject(q);
@@ -214,7 +214,7 @@ public void unsubscribe() {
214214
}
215215

216216
/* for unit tests */RxRingBuffer() {
217-
this(new SynchronizedQueue<Queue>(SIZE), SIZE);
217+
this(new SynchronizedQueue<Object>(SIZE), SIZE);
218218
}
219219

220220
/**

rxjava-core/src/main/java/rx/internal/util/SubscriptionRandomList.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,15 @@ public void clear() {
113113
}
114114

115115
public void forEach(Action1<T> action) {
116-
Object[] ss;
116+
T[] ss=null;
117117
synchronized (this) {
118118
if (unsubscribed || subscriptions == null) {
119119
return;
120120
}
121-
ss = subscriptions.toArray();
121+
ss = subscriptions.toArray(ss);
122122
}
123-
for (Object t : ss) {
124-
action.call((T) t);
123+
for (T t : ss) {
124+
action.call(t);
125125
}
126126
}
127127

rxjava-core/src/test/java/rx/internal/util/IndexedRingBufferTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,13 @@ public void testForEachAcrossSections() {
211211
buffer.add(i);
212212
}
213213

214-
final ArrayList<String> list = new ArrayList<String>();
214+
final ArrayList<Integer> list = new ArrayList<Integer>();
215215
int nextIndex = buffer.forEach(accumulate(list), 5000);
216216
assertEquals(10000, list.size());
217-
assertEquals(5000, list.get(0));
218-
assertEquals(9999, list.get(4999));
219-
assertEquals(0, list.get(5000));
220-
assertEquals(4999, list.get(9999));
217+
assertEquals(Integer.valueOf(5000), list.get(0));
218+
assertEquals(Integer.valueOf(9999), list.get(4999));
219+
assertEquals(Integer.valueOf(0), list.get(5000));
220+
assertEquals(Integer.valueOf(4999), list.get(9999));
221221
assertEquals(5000, nextIndex);
222222
}
223223

@@ -364,11 +364,11 @@ public void call() {
364364
assertEquals(0, exceptions.size());
365365
}
366366

367-
private Func1<Object, Boolean> accumulate(final ArrayList list) {
368-
return new Func1<Object, Boolean>() {
367+
private <T> Func1<T, Boolean> accumulate(final ArrayList<T> list) {
368+
return new Func1<T, Boolean>() {
369369

370370
@Override
371-
public Boolean call(Object t1) {
371+
public Boolean call(T t1) {
372372
list.add(t1);
373373
return true;
374374
}

rxjava-core/src/test/java/rx/internal/util/RxRingBufferBase.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,15 @@
1515
*/
1616
package rx.internal.util;
1717

18-
import static org.junit.Assert.assertEquals;
1918
import static org.junit.Assert.assertTrue;
2019
import static org.junit.Assert.fail;
2120

2221
import java.util.Arrays;
23-
import java.util.concurrent.CountDownLatch;
24-
import java.util.concurrent.atomic.AtomicInteger;
2522

2623
import org.junit.Test;
2724

28-
import rx.Producer;
29-
import rx.Scheduler;
30-
import rx.Subscriber;
3125
import rx.exceptions.MissingBackpressureException;
32-
import rx.functions.Action0;
3326
import rx.observers.TestSubscriber;
34-
import rx.schedulers.Schedulers;
3527

3628
public abstract class RxRingBufferBase {
3729

@@ -59,7 +51,6 @@ public void addAndPollFailBackpressure() throws MissingBackpressureException {
5951

6052
RxRingBuffer b = createRingBuffer();
6153

62-
TestSubscriber<Object> s = new TestSubscriber<Object>();
6354
try {
6455
for (int i = 0; i < RxRingBuffer.SIZE; i++) {
6556
// System.out.println("Add: " + i);
@@ -82,7 +73,6 @@ public void addAndPollFailBackpressure() throws MissingBackpressureException {
8273
@Test
8374
public void addAndPoll() throws MissingBackpressureException {
8475
RxRingBuffer b = createRingBuffer();
85-
TestSubscriber<Object> s = new TestSubscriber<Object>();
8676
b.onNext("o");
8777
b.onNext("o");
8878
b.poll();

0 commit comments

Comments
 (0)