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

Call LineRecorder receiver's closeStream() (#433) #434

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ record = new StringBuilder(SB_CAPACITY);

@Override
public void closeStream() {
assert !isClosed();
Copy link
Member

Choose a reason for hiding this comment

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

This is rather unusual. AFAICS, no other module does this (inside closeStream() that is).

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you really mean assert !isClosed(); ? There are alternatives like if (!isClosed) {. Does it make any difference, semantically? Would it be better to use the if statement?

Copy link
Member

Choose a reason for hiding this comment

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

The assert means you can't (shouldn't) close a closed stream, while the conditional simply ignores an already closed stream. I think the latter behaviour would be preferable in general.

getReceiver().process(record.toString());
getReceiver().closeStream();
isClosed = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public void shouldEmitLastRecordWithoutRecordMarkerWhenClosingStream() {
LINE_SEPARATOR +
RECORD3_PART2 +
LINE_SEPARATOR);
ordered.verify(receiver).closeStream();
ordered.verifyNoMoreInteractions();
}

Expand Down