Skip to content

2.x: subscribers/observers tests #3333

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

Merged
merged 1 commit into from
Sep 9, 2015
Merged
Show file tree
Hide file tree
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
44 changes: 44 additions & 0 deletions src/main/java/io/reactivex/exceptions/CompositeException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Copyright 2015 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
* the License for the specific language governing permissions and limitations under the License.
*/

package io.reactivex.exceptions;

import java.util.*;

public final class CompositeException extends RuntimeException {
/** */
private static final long serialVersionUID = 2004635183691362481L;

public CompositeException() {
super();
}

public CompositeException(String message) {
super(message);
}

public List<Throwable> getExceptions() {
Throwable cause = getCause();
Throwable[] suppressed = getSuppressed();
List<Throwable> list = new ArrayList<>(cause != null
? 1 + suppressed.length : suppressed.length);
if (cause != null) {
list.add(cause);
}
for (Throwable t : suppressed) {
list.add(t);
}

return list;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright 2015 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
* the License for the specific language governing permissions and limitations under the License.
*/

package io.reactivex.exceptions;

public final class OnCompleteFailedException extends RuntimeException {
/** */
private static final long serialVersionUID = -6179993283427447098L;

public OnCompleteFailedException(Throwable cause) {
super(cause);
}

}
23 changes: 23 additions & 0 deletions src/main/java/io/reactivex/exceptions/OnErrorFailedException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Copyright 2015 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
* the License for the specific language governing permissions and limitations under the License.
*/

package io.reactivex.exceptions;

public final class OnErrorFailedException extends RuntimeException {
/** */
private static final long serialVersionUID = 2656125445290831911L;

public OnErrorFailedException(Throwable cause) {
super(cause);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Copyright 2015 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
* the License for the specific language governing permissions and limitations under the License.
*/

package io.reactivex.exceptions;

public final class OnErrorNotImplementedException extends RuntimeException {
/** */
private static final long serialVersionUID = -3698670655303683299L;

public OnErrorNotImplementedException() {
super();
}

public OnErrorNotImplementedException(String message, Throwable cause) {
super(message, cause);
}

public OnErrorNotImplementedException(String message) {
super(message);
}

public OnErrorNotImplementedException(Throwable cause) {
super(cause);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright 2015 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
* the License for the specific language governing permissions and limitations under the License.
*/

package io.reactivex.exceptions;

public final class UnsubscribeFailedException extends RuntimeException {
/** */
private static final long serialVersionUID = 8947024194181365640L;

public UnsubscribeFailedException(Throwable cause) {
super(cause);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ static final class DoOnEachSubscriber<T> implements Subscriber<T> {

Subscription s;

boolean done;

public DoOnEachSubscriber(
Subscriber<? super T> actual,
Consumer<? super T> onNext,
Expand All @@ -75,6 +77,9 @@ public void onSubscribe(Subscription s) {

@Override
public void onNext(T t) {
if (done) {
return;
}
try {
onNext.accept(t);
} catch (Throwable e) {
Expand All @@ -88,6 +93,11 @@ public void onNext(T t) {

@Override
public void onError(Throwable t) {
if (done) {
RxJavaPlugins.onError(t);
return;
}
done = true;
try {
onError.accept(t);
} catch (Throwable e) {
Expand All @@ -104,6 +114,10 @@ public void onError(Throwable t) {

@Override
public void onComplete() {
if (done) {
return;
}
done = true;
try {
onComplete.run();
} catch (Throwable e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import io.reactivex.plugins.RxJavaPlugins;

/**
* A subscriber cancels the subscription sent to it
* A subscriber that cancels the subscription sent to it
* and ignores all events (onError is forwarded to RxJavaPlugins though).
*/
public enum CancelledSubscriber implements Subscriber<Object> {
Expand Down
Loading