-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
HBASE-25451 Upgrade commons-io to 2.8.0 #2825
Conversation
@@ -832,7 +832,7 @@ private void finishActiveMasterInitialization(MonitoredTask status) throws IOExc | |||
HBaseFsck.createLockRetryCounterFactory(this.conf).create()); | |||
} finally { | |||
if (result != null) { | |||
IOUtils.closeQuietly(result.getSecond()); | |||
Closeables.close(result.getSecond(), true); |
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.
What is the difference about Closeables.close and IOUtils.close?
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.
Closeables.close(c, true) will swallow the IOException thrown while IOUtils.close will not.
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.
Seems there are three methods you used: Closeables.closeQuietly, Closeables.close, IOUtils.closeQuietly. Do we have a developer guide doc about what we recommend to use?
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.
Closeables.close will still throw IOExceptions on the method signature, so usually it is only suitable to be used in UT, where we are free to change the method signature.
IOUtils.closeQuietly will not throw any exceptions but you need to pass in a consumer to process the IOException(usually just a logging).
Closeables.closeQuietly is for closing Reader and InputStream, where we will not throw any exceptions.
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.
And in general, I do not have very strong opinion on forcing these rules, developers are free to use these methods, just not use a deprecated one...
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.
IOUtils.closeQuietly is also deprecated with a long time -- apache/commons-io@ce2b3e8
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.
As is Closeables#closeQuietly... google/guava#1118
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.
For IOUtils.closeQuietly, now it provides a version with a consumer parameter to process the IOException which is not deprecated.
For Closeables.closeQuirtly, the version which takes a Closeable as parameter has already been removed for a long time, but the version which takes a InputStream or a Reader is still available and is not deprecated.
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -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
@@ -832,7 +832,7 @@ private void finishActiveMasterInitialization(MonitoredTask status) throws IOExc | |||
HBaseFsck.createLockRetryCounterFactory(this.conf).create()); | |||
} finally { | |||
if (result != null) { | |||
IOUtils.closeQuietly(result.getSecond()); | |||
Closeables.close(result.getSecond(), true); |
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.
IOUtils.closeQuietly is also deprecated with a long time -- apache/commons-io@ce2b3e8
@@ -832,7 +832,7 @@ private void finishActiveMasterInitialization(MonitoredTask status) throws IOExc | |||
HBaseFsck.createLockRetryCounterFactory(this.conf).create()); | |||
} finally { | |||
if (result != null) { | |||
IOUtils.closeQuietly(result.getSecond()); | |||
Closeables.close(result.getSecond(), true); |
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.
As is Closeables#closeQuietly... google/guava#1118
Signed-off-by: Guanghao Zhang <zghao@apache.org> Signed-off-by: stack <stack@apache.org>
No description provided.