Skip to content

Commit

Permalink
Fix unserialized access to subject on Marshmallow
Browse files Browse the repository at this point in the history
Closes #313
  • Loading branch information
aperfilyev committed Nov 23, 2018
1 parent 524c87b commit 91b676e
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import io.reactivex.Observable;
import io.reactivex.functions.Action;
import io.reactivex.subjects.PublishSubject;
import io.reactivex.subjects.Subject;

import static com.github.pwittchen.reactivenetwork.library.rx2.ReactiveNetwork.LOG_TAG;

Expand All @@ -48,12 +49,13 @@

@SuppressWarnings("NullAway") // it has to be initialized in the Observable due to Context
private ConnectivityManager.NetworkCallback networkCallback;
private PublishSubject<Connectivity> connectivitySubject = PublishSubject.create();
private BroadcastReceiver idleReceiver;
private final Subject<Connectivity> connectivitySubject;
private final BroadcastReceiver idleReceiver;

@SuppressWarnings("NullAway") // networkCallback cannot be initialized here
public MarshmallowNetworkObservingStrategy() {
this.idleReceiver = createIdleBroadcastReceiver();
this.connectivitySubject = PublishSubject.<Connectivity>create().toSerialized();
}

@Override public Observable<Connectivity> observeNetworkConnectivity(final Context context) {
Expand Down

0 comments on commit 91b676e

Please sign in to comment.