Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unserialized access to subject on Marshmallow #314

Merged
merged 1 commit into from
Dec 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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