You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* <dd>{@code publish} does not operate by default on a particular {@link Scheduler}.</dd>
8343
-
* </dl>
8344
-
*
8345
-
* @param <R>
8346
-
* the type of items emitted by the resulting ObservableSource
8347
-
* @param selector
8348
-
* a function that can use the multicasted source sequence as many times as needed, without
8349
-
* causing multiple subscriptions to the source sequence. Observers to the given source will
8350
-
* receive all notifications of the source from the time of the subscription forward.
8351
-
* @param bufferSize
8352
-
* the number of elements to prefetch from the current Observable
8353
-
* @return an Observable that emits the results of invoking the selector on the items emitted by a {@link ConnectableObservable} that shares a single subscription to the underlying sequence
Copy file name to clipboardExpand all lines: src/main/java/io/reactivex/internal/operators/observable/ObservableBuffer.java
+8-17
Original file line number
Diff line number
Diff line change
@@ -106,17 +106,15 @@ public boolean isDisposed() {
106
106
@Override
107
107
publicvoidonNext(Tt) {
108
108
Ub = buffer;
109
-
if (b == null) {
110
-
return;
111
-
}
112
-
113
-
b.add(t);
109
+
if (b != null) {
110
+
b.add(t);
114
111
115
-
if (++size >= count) {
116
-
actual.onNext(b);
112
+
if (++size >= count) {
113
+
actual.onNext(b);
117
114
118
-
size = 0;
119
-
createBuffer();
115
+
size = 0;
116
+
createBuffer();
117
+
}
120
118
}
121
119
}
122
120
@@ -185,21 +183,14 @@ public void onNext(T t) {
185
183
Ub;
186
184
187
185
try {
188
-
b = bufferSupplier.call();
186
+
b = ObjectHelper.requireNonNull(bufferSupplier.call(), "The bufferSupplier returned a null collection. Null values are generally not allowed in 2.x operators and sources.");
189
187
} catch (Throwablee) {
190
188
buffers.clear();
191
189
s.dispose();
192
190
actual.onError(e);
193
191
return;
194
192
}
195
193
196
-
if (b == null) {
197
-
buffers.clear();
198
-
s.dispose();
199
-
actual.onError(newNullPointerException("onNext called with null. Null values are generally not allowed in 2.x operators and sources."));
0 commit comments