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 issue #1173 #1178

Merged
merged 6 commits into from
May 19, 2014
Merged

Fix issue #1173 #1178

merged 6 commits into from
May 19, 2014

Conversation

zsxwing
Copy link
Member

@zsxwing zsxwing commented May 9, 2014

In Subscriber.apply(rx.Subscriber), asJavaObserver and asJavaSubscription will be set to null because the parent class will be initialized with asJavaSubscriber==null. #1173.

This PR did the initialization again in the subclass.

@zsxwing
Copy link
Member Author

zsxwing commented May 10, 2014

@headinthebox 's example also inspires me that the inner Subscriber can not be unsubscribed from outside if RxScala does not provide a subscriber(Subscriber). Because subscriber(Observer) will create a new Subscriber but won't chain the Subscription in the outer Subscriber. The test is testUnsubscribeForSubscriber.

/cc @samuelgruetter

@cloudbees-pull-request-builder

RxJava-pull-requests #1096 FAILURE
Looks like there's a problem with this pull request

def subscribe(subscriber: Subscriber[T]): Subscription = {
// Add the casting to avoid compile error "ambiguous reference to overloaded definition"
val thisJava = asJavaObservable.asInstanceOf[rx.Observable[T]]
thisJava.subscribe(subscriber.asJavaSubscriber)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compile error of removing casting:

error: ambiguous reference to overloaded definition,
[ant:scalac] both method subscribe in class Observable of type (x$1: rx.Subscriber[_ >: _$1], x$2: rx.Scheduler)rx.Subscription
[ant:scalac] and  method subscribe in class Observable of type (x$1: rx.Observer[_ >: _$1], x$2: rx.Scheduler)rx.Subscription
[ant:scalac] match argument types (rx.Subscriber[_$2],rx.lang.scala.Scheduler) and expected result type rx.lang.scala.Subscription
[ant:scalac]     asJavaObservable.subscribe(subscriber.asJavaSubscriber, scheduler)
[ant:scalac]                      ^

@cloudbees-pull-request-builder

RxJava-pull-requests #1097 FAILURE
Looks like there's a problem with this pull request

@cloudbees-pull-request-builder

RxJava-pull-requests #1110 FAILURE
Looks like there's a problem with this pull request

@cloudbees-pull-request-builder

RxJava-pull-requests #1113 FAILURE
Looks like there's a problem with this pull request

@zsxwing
Copy link
Member Author

zsxwing commented May 15, 2014

@samuelgruetter any suggestions about this one?

@benjchristensen
Copy link
Member

Waiting on feedback and confirmation.

@headinthebox
Copy link
Contributor

I'll have a look over the weekend.

@samuelgruetter
Copy link
Contributor

The problem is that the three vals asJavaObserver, asJavaSubscription, asJavaSubscriber, defined in trait Subscriber, are not in the right order. It should first define asJavaSubscriber, because the other two are defined in terms of asJavaSubscriber, and initialization of vals is done sequentially.

@zsxwing
Copy link
Member Author

zsxwing commented May 19, 2014

Good catch.

@cloudbees-pull-request-builder

RxJava-pull-requests #1124 SUCCESS
This pull request looks good

@headinthebox
Copy link
Contributor

thanks for staying on top!

@samuelgruetter
Copy link
Contributor

LGTM

@headinthebox
Copy link
Contributor

@benjchristensen can you merge this?

benjchristensen added a commit that referenced this pull request May 19, 2014
@benjchristensen benjchristensen merged commit 62266af into ReactiveX:master May 19, 2014
@headinthebox
Copy link
Contributor

Thanks!

@zsxwing zsxwing deleted the issue1173 branch May 20, 2014 01:43
@benjchristensen benjchristensen mentioned this pull request May 20, 2014
@benjchristensen benjchristensen mentioned this pull request Jun 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants