Skip to content

Remove unnecessary expressions in AsyncItemWriter #4009

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

Closed
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ public void write(List<? extends Future<T>> items) throws Exception {
T item = future.get();

if(item != null) {
list.add(future.get());
list.add(item);
}
}
catch (ExecutionException e) {
Throwable cause = e.getCause();

if(cause != null && cause instanceof Exception) {
if(cause instanceof Exception) {
logger.debug("An exception was thrown while processing an item", e);

throw (Exception) cause;
Expand All @@ -81,8 +81,10 @@ public void write(List<? extends Future<T>> items) throws Exception {
}
}
}

delegate.write(list);

if (!list.isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What to do with empty chunks is a decision to be made by the delegate writer, not the asynchronous item writer. A concrete example is that when the delegate logs a warning about receiving an empty chunk, with this change, the log message would disappear. The role of the async item writer is to unwrap Futures objects and pass them to the delegate writer without any modification or additional logic. I will omit this change from the PR.

delegate.write(list);
}
}

@Override
Expand Down