Skip to content

1.x: Add action != null check in OperatorFinally #3436

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

Conversation

artem-zinnatullin
Copy link
Contributor

Part of #3435.

Personally, I'd also add same test to Observable.finallyDo() and Single.finallyDo() because there are no guarantees that in future they will use exact same operator as implementation and this contract is more a contract of Observable.finallyDo() and Single.finallyDo().

@@ -33,6 +33,9 @@
final Action0 action;

public OperatorFinally(Action0 action) {
if (action == null) {
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather put these checks into Observable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This operator will be used in Single.finallyDo(), I don't want to copy-paste this :)

Copy link
Member

Choose a reason for hiding this comment

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

The benefit of having the null check in the caller is that there is no allocation happening in case the action is null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Saving one allocation does not matter in this case because in most of the cases app will crash after this exception :)

@akarnokd akarnokd added the Bug label Oct 12, 2015
@akarnokd akarnokd added this to the 1.0.x milestone Oct 12, 2015
@akarnokd
Copy link
Member

👍

@akarnokd akarnokd changed the title Add action != null check in OperatorFinally 1.x: Add action != null check in OperatorFinally Nov 12, 2015
@zsxwing
Copy link
Member

zsxwing commented Nov 13, 2015

👍

akarnokd added a commit that referenced this pull request Nov 13, 2015
…-action-check

1.x: Add action != null check in OperatorFinally
@akarnokd akarnokd merged commit 5c1c4a7 into ReactiveX:1.x Nov 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants