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

Remove nulls from UncheckedProc #885 #1029

Merged
merged 1 commit into from
Jan 24, 2019
Merged
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
11 changes: 7 additions & 4 deletions src/main/java/org/cactoos/func/UncheckedProc.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
*/
package org.cactoos.func;

import java.io.IOException;
import java.io.UncheckedIOException;
import org.cactoos.Proc;

/**
Expand All @@ -32,9 +34,6 @@
*
* @param <X> Type of input
* @since 0.2
* @todo #861:30min Avoid usage of null value in UncheckedProc.exec(X) which is
* against design principles.
* Please take a look on #551 and #843 for more details.
*/
public final class UncheckedProc<X> implements Proc<X> {

Expand All @@ -53,7 +52,11 @@ public UncheckedProc(final Proc<X> prc) {

@Override
public void exec(final X input) {
new UncheckedFunc<>(new FuncOf<>(this.proc, null)).apply(input);
try {
Copy link
Contributor

Choose a reason for hiding this comment

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

@victornoel Please, can you add some tests here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@fabriciofx there already are tests for this class

Copy link
Contributor

Choose a reason for hiding this comment

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

@victornoel Right. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

@victornoel you can use CheckedScalar here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@llorllale if I use CheckedScalar then I will need to specify an object to be returned, and then I will put null :) FuncOf does use one of the Scalar class for example

new IoCheckedProc<>(this.proc).exec(input);
} catch (final IOException ex) {
throw new UncheckedIOException(ex);
}
}

}