@@ -234,11 +234,11 @@ public static <T> BehaviorProcessor<T> create() {
234
234
*/
235
235
BehaviorProcessor (T defaultValue ) {
236
236
this ();
237
- this .value .lazySet (Objects . requireNonNull ( defaultValue , "defaultValue is null" ) );
237
+ this .value .lazySet (defaultValue );
238
238
}
239
239
240
240
@ Override
241
- protected void subscribeActual (Subscriber <? super T > s ) {
241
+ protected void subscribeActual (@ NonNull Subscriber <? super T > s ) {
242
242
BehaviorSubscription <T > bs = new BehaviorSubscription <>(s , this );
243
243
s .onSubscribe (bs );
244
244
if (add (bs )) {
@@ -258,7 +258,7 @@ protected void subscribeActual(Subscriber<? super T> s) {
258
258
}
259
259
260
260
@ Override
261
- public void onSubscribe (Subscription s ) {
261
+ public void onSubscribe (@ NonNull Subscription s ) {
262
262
if (terminalEvent .get () != null ) {
263
263
s .cancel ();
264
264
return ;
@@ -267,7 +267,7 @@ public void onSubscribe(Subscription s) {
267
267
}
268
268
269
269
@ Override
270
- public void onNext (T t ) {
270
+ public void onNext (@ NonNull T t ) {
271
271
ExceptionHelper .nullCheck (t , "onNext called with a null value." );
272
272
273
273
if (terminalEvent .get () != null ) {
@@ -281,7 +281,7 @@ public void onNext(T t) {
281
281
}
282
282
283
283
@ Override
284
- public void onError (Throwable t ) {
284
+ public void onError (@ NonNull Throwable t ) {
285
285
ExceptionHelper .nullCheck (t , "onError called with a null Throwable." );
286
286
if (!terminalEvent .compareAndSet (null , t )) {
287
287
RxJavaPlugins .onError (t );
@@ -316,14 +316,13 @@ public void onComplete() {
316
316
* <p>History: 2.0.8 - experimental
317
317
* @param t the item to emit, not null
318
318
* @return true if the item was emitted to all Subscribers
319
+ * @throws NullPointerException if {@code t} is {@code null}
319
320
* @since 2.2
320
321
*/
321
322
@ CheckReturnValue
322
- public boolean offer (T t ) {
323
- if (t == null ) {
324
- onError (ExceptionHelper .createNullPointerException ("offer called with a null value." ));
325
- return true ;
326
- }
323
+ public boolean offer (@ NonNull T t ) {
324
+ ExceptionHelper .nullCheck (t , "offer called with a null value." );
325
+
327
326
BehaviorSubscription <T >[] array = subscribers .get ();
328
327
329
328
for (BehaviorSubscription <T > s : array ) {
0 commit comments