-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Adding Close selector to prevent FD/FIFO leaks #3707
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
Changes from 5 commits
178b94b
d78baf4
d3f94ec
5ffda69
7794f3a
71341c2
409b3b1
4428d41
7b80ef3
9175d0e
e7703ff
76a166f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright 2002-2021 the original author or authors. | ||
* Copyright 2002-2022 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
|
@@ -620,6 +620,14 @@ public void write(int b) throws IOException { | |
|
||
@Override | ||
public void close() { | ||
if (this.selector != null) { | ||
try { | ||
this.selector.close(); | ||
} | ||
catch (IOException e) { | ||
// do nothing | ||
} | ||
} | ||
doClose(); | ||
} | ||
|
||
|
@@ -663,7 +671,6 @@ protected synchronized void doWrite(ByteBuffer buffer) throws IOException { | |
remaining = buffer.remaining(); | ||
} | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is wrong: every member (even last method) of the class has to be surrounded with blank lines. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure where this empty line is missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just bring it back and push! |
||
} | ||
|
||
/** | ||
|
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.
I don't think such an implementation is OK.
This
doClose()
is exactly that one in the outer class, so thisclose()
is going to be called again.And so on in recursive manner.
I'm not sure what was an original intention with such a delegation, but we need to be sure that we don't do a recursion.
Could you, please, double check the solution?
Also the
catch
block must be on a new line.Be sure run
\gradlew clean :spring-integration-ip:check
before pushing the change to the PR.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.
I am not sure what's going on, but GitHub is not rendering the changes from all 5 commits; I can only see this change.
It looks like a bug that we never closed the output stream; we would have hit the stack overflow problem if we did; day one issue, I think.
I believe we can just remove that
doClose()
call here.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.
Yes, and since the output
close()
is never called from the outside, it is safe to have it call it from connection close.And yes: still keep a
selector.close()
😄