-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Closed
Labels
Description
This seems to be isolated to the first chunk.
@Test
public void testDuplicate() throws Exception {
final Set<Integer> unique = new HashSet<Integer>();
Observable.create(new OnSubscribeFunc<Integer>() {
@Override
public Subscription onSubscribe(final Observer<? super Integer> t1) {
final Future<?> t = Executors.newSingleThreadExecutor().submit(new Runnable() {
@Override
public void run() {
int count = 0;
for (int i = 0; i < 11; i++) {
t1.onNext(count++);
try {
Thread.sleep(10);
} catch (InterruptedException e) {
}
}
}
});
return new Subscription() {
@Override
public void unsubscribe() {
t.cancel(true);
}
};
}
})
.buffer(100, 100, TimeUnit.MILLISECONDS)
.subscribe(new Action1<List<Integer>>() {
@Override
public void call(List<Integer> t1) {
if (t1.isEmpty())
return;
LOG.info(t1.toString());
for (Integer i : t1) {
synchronized (unique) {
if (unique.contains(i)) {
LOG.error("Duplicate for " + i);
}
Assert.assertFalse(unique.contains(i));
unique.add(i);
}
}
}
});
Thread.sleep(10000);
}