-
Notifications
You must be signed in to change notification settings - Fork 267
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
Deprecate Tasks.par(...) for safer alternative Task.par(...) that does not throw IllegalArgumentException on empty collection. #113
Conversation
…s not throw IllegalArgumentException on empty collection.
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.
Minor comments regarding javadoc.
Could you also update CHANGELOG ?
* {@link com.linkedin.parseq.ParTask#getTasks()} or | ||
* {@link com.linkedin.parseq.ParTask#getSuccessful()} to get results in this | ||
* case. | ||
* <p> |
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.
Document behavior when when Iterable is empty.
* | ||
* @param tasks the tasks to run in parallel | ||
* @return The results of the tasks | ||
* @deprecated As of 2.0.0, replaced by {@link Task#par(Iterable) Task.par} |
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.
Document difference in behavior between this method and the Task.par(Iterable)
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.
Ship it!
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.
looks good. thanks! please make javadoc changes as suggested by Jarek.
Great work on this! Can't wait to see this get merged, we just had a production bug because of the old behavior. Thanks for taking initiative and putting up a fix so quickly. |
@@ -63,6 +68,11 @@ public ParTaskImpl(final String name, final Iterable<? extends Task<? extends T> | |||
protected Promise<List<T>> run(final Context context) throws Exception { | |||
final SettablePromise<List<T>> result = Promises.settable(); | |||
|
|||
if (_tasks.isEmpty()) { | |||
result.done(Collections.<T>emptyList()); |
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.
maybe even return Promises.value(Collections.<T>emptyList());
and move it before line 69?
Deprecate Tasks.par(...) for safer alternative Task.par(...) that does not throw IllegalArgumentException on empty collection.