-
Notifications
You must be signed in to change notification settings - Fork 30
Unit test and fix for bug (#154) #155
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
Conversation
| s.onSubscribe(parent); | ||
|
|
||
| single.subscribe(parent); | ||
| s.onSubscribe(parent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This violates the RS contract. OnSubscribe must happen before an other calls to onXXX.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will restore origin subscribe() flow
| TestSubscriber<Object> ts = new TestSubscriber<Object>(); | ||
|
|
||
| toSingle(toPublisher(Observable.just(1))).subscribe(ts); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't change existing unit tests and add new ones instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will restore original just() unit test and will add singleJust() that was hanging.
|
The bug is that there is a |
|
Maybe its better if you start over from a fresh branch of main. |
|
Well, I started over from the tip of 1.x and added the unit test. However, adding |
|
I see. Try this: @Override
public void onSuccess(T value) {
if (cancelled) {
return;
}
if (value == null) {
state.lazySet(HAS_REQUEST_HAS_VALUE);
actual.onError(new NullPointerException("value"));
return;
}
for (;;) {
int s = state.get();
if (s == NO_REQUEST_HAS_VALUE || s == HAS_REQUEST_HAS_VALUE || cancelled) {
break;
} else
if (s == HAS_REQUEST_NO_VALUE) {
state.lazySet(HAS_REQUEST_HAS_VALUE);
actual.onNext(value);
if (!cancelled) {
actual.onComplete();
}
break;
} else {
this.value = value;
if (state.compareAndSet(s, NO_REQUEST_HAS_VALUE)) {
break;
}
}
}
}
@Override
public void onError(Throwable error) {
if (cancelled) {
return;
}
state.lazySet(HAS_REQUEST_HAS_VALUE);
actual.onError(error);
}
@Override
public void request(long n) {
if (n > 0) {
for (;;) {
int s = state.get();
if (s == HAS_REQUEST_HAS_VALUE || s == HAS_REQUEST_NO_VALUE || cancelled) {
break;
} else
if (s == NO_REQUEST_HAS_VALUE) {
if (state.compareAndSet(s, HAS_REQUEST_HAS_VALUE)) {
T v = value;
value = null;
actual.onNext(v);
if (!cancelled) {
actual.onComplete();
}
}
break;
}
if (state.compareAndSet(NO_REQUEST_NO_VALUE, HAS_REQUEST_NO_VALUE)) {
break;
}
}
}
} |
|
Closing via #156. |
No description provided.