Skip to content

Commit 67f708b

Browse files
Forward from Object to Observer overload
Be more lenient in handling the overloaded methods.
1 parent 734c728 commit 67f708b

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

rxjava-core/src/main/java/org/rx/reactive/Observable.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
22
* Copyright 2013 Netflix, Inc.
3-
*
3+
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -136,9 +136,10 @@ public void onNext(Object args) {
136136
}
137137

138138
@SuppressWarnings({ "rawtypes", "unchecked" })
139-
public Subscription subscribe(final Object onNext) {
140-
if (onNext instanceof Observer) {
141-
throw new RuntimeException("Observers are not intended to be passed to this generic method. Your generic type is most likely wrong. This method is for dynamic code to send in closures.");
139+
public Subscription subscribe(final Object o) {
140+
if (o instanceof Observer) {
141+
// in case a dynamic language is not correctly handling the overloaded methods and we receive an Observer just forward to the correct method.
142+
return subscribe((Observer) o);
142143
}
143144
return subscribe(new Observer() {
144145

@@ -152,10 +153,10 @@ public void onError(Exception e) {
152153
}
153154

154155
public void onNext(Object args) {
155-
if (onNext == null) {
156+
if (o == null) {
156157
throw new RuntimeException("onNext must be implemented");
157158
}
158-
executeCallback(onNext, args);
159+
executeCallback(o, args);
159160
}
160161

161162
});

0 commit comments

Comments
 (0)