Skip to content

Commit 0e1cf35

Browse files
committed
Removed synchronized block as per RxJava guidelines (6.7).
1 parent 77b7828 commit 0e1cf35

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

rxjava-core/src/main/java/rx/operators/OperationSwitch.java

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -93,29 +93,27 @@ public void onError(Exception e) {
9393

9494
@Override
9595
public void onNext(Observable<T> args) {
96-
synchronized (subscription) {
97-
Subscription previousSubscription = subscription.get();
98-
if (previousSubscription != null) {
99-
previousSubscription.unsubscribe();
100-
}
101-
102-
subscription.set(args.subscribe(new Observer<T>() {
103-
@Override
104-
public void onCompleted() {
105-
// Do nothing.
106-
}
107-
108-
@Override
109-
public void onError(Exception e) {
110-
// Do nothing.
111-
}
112-
113-
@Override
114-
public void onNext(T args) {
115-
observer.onNext(args);
116-
}
117-
}));
96+
Subscription previousSubscription = subscription.get();
97+
if (previousSubscription != null) {
98+
previousSubscription.unsubscribe();
11899
}
100+
101+
subscription.set(args.subscribe(new Observer<T>() {
102+
@Override
103+
public void onCompleted() {
104+
// Do nothing.
105+
}
106+
107+
@Override
108+
public void onError(Exception e) {
109+
// Do nothing.
110+
}
111+
112+
@Override
113+
public void onNext(T args) {
114+
observer.onNext(args);
115+
}
116+
}));
119117
}
120118
}
121119

0 commit comments

Comments
 (0)