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

Fix NettyInputStream ByteBuf leak #4222

Merged
merged 5 commits into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -87,6 +87,8 @@ public int read(byte[] b, int off, int len) throws IOException {

Copy link
Contributor

Choose a reason for hiding this comment

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

could you please update copyright year in both files (to 2019) - copyright header at the top of each file?

Copy link
Contributor

Choose a reason for hiding this comment

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

thank you for changes, and a question - you are changing method read(byte[] b, int off, int len) but immediately under this method there is method read() without any parameters, but inner logic looks very similar, except the very reading. So, the question - shall InputStream take be closed as well in the read() method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, I refactored the code a bit to avoid this mistake in the future.

if (take.available() > 0) {
isList.addFirst(take);
} else {
take.close();
}

return read;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void run() {
ByteBuf content = httpContent.content();

if (content.isReadable()) {
isList.add(new ByteBufInputStream(content));
isList.add(new ByteBufInputStream(content, true));
}

if (msg instanceof LastHttpContent) {
Expand Down