-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
HADOOP-17788. Replace IOUtils#closeQuietly usages by Hadoop's own utility #3171
Conversation
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.
A key question is : why not use closeStream()
which hides the fact that a null logger is passed in, and allows us to do things differently in future
@@ -322,7 +322,7 @@ public NewShmInfo createNewMemorySegment(String clientName, | |||
shm = new RegisteredShm(clientName, shmId, fis, this); | |||
} finally { | |||
if (shm == null) { | |||
IOUtils.closeQuietly(fis); | |||
IOUtils.cleanupWithLogger(null, fis); |
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.
why not use closeStream(fis)
?
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.
Sounds good, closeStream()
is also accessible and does the same so it's cleaner than passing null for each. Let me make this change.
@@ -105,7 +105,7 @@ public MappableBlock load(long length, FileInputStream blockIn, | |||
+ ", [cached path={}, address={}, length={}]", key, filePath, | |||
region.getAddress(), length); | |||
} finally { | |||
IOUtils.closeQuietly(blockChannel); | |||
org.apache.hadoop.io.IOUtils.cleanupWithLogger(null, blockChannel); |
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.
any reason not to import?
To fix deprecation warning, I perfer using try-with-resources rather than replacing with our internal replacement. |
@aajisaka it seems only few places can live with |
104c035
to
eec10e2
Compare
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
@aajisaka @steveloughran I have addressed review comments. Could you please take a look? |
Mixed feelings there. I went through a lot of grief in HADOOP-16998/#2073 related to exceptions being raised in try with resources while a prior exception has been raised. The JVM will attach any ex raised in the resource closed to the initial ex via addSuppressed(), but if somehow it's the same exception you get an IllegalArgumentException with all stack traces lost. so, good
bad
ugly
|
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.
+1 fro me
💔 -1 overall
This message was automatically generated. |
Thanks for the review @steveloughran and thanks for the example of how JDK can produce |
💔 -1 overall
This message was automatically generated. |
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.
+1.
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.
+1. Thank you for the cleanup!
I ran all the failed tests locally and they passed.
yeah, stupid thing for them to do. wasb was being clever about caching and rethrowing the same exception in close() as in the read(), and some code using it above hadoop was failing. what a pain. |
Merged it. Thanks for your contribution, @virajjasani. Thanks for your reviews and your variable comments, @steveloughran and @aajisaka. |
…lity (apache#3171) Reviewed-by: Steve Loughran <stevel@apache.org> Reviewed-by: Akira Ajisaka <aajisaka@apache.org> Signed-off-by: Takanobu Asanuma <tasanuma@apache.org>
IOUtils#closeQuietly is deprecated since 2.6 release of commons-io without any replacement. Since we already have good replacement available in Hadoop's own IOUtils, we should use it.