-
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-29026 Replace some deprecated calls #6585
base: master
Are you sure you want to change the base?
Conversation
PDavid
commented
Jan 8, 2025
•
edited
Loading
edited
- Replaced the following deprecated methods:
- java.net.URLEncoder.encode(String) -> java.net.URLEncoder.encode(String, Charset)
- org.apache.hadoop.util.StringUtils.humanReadableInt(long) -> org.apache.hadoop.util.StringUtils.TraditionalBinaryPrefix.long2String(long, "", 1): For this a new static util method is introduced: org.apache.hadoop.hbase.util.Strings.humanReadableInt
- org.apache.hadoop.fs.FileSystem.getLength(Path) -> getFileStatus(Path).getLen()
- org.apache.hadoop.hbase.ServerName.getStartcode() -> org.apache.hadoop.hbase.ServerName.getStartCode()
- Also removed unused imports in the touched JSP files.
+ master.getRegionServerInfoPort(addr) + "/rs-status"; | ||
%> | ||
<tr> | ||
<td><a href="<%= url %>"><%= StringEscapeUtils.escapeHtml4(addr.getHostname().toString()) |
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 bit unrelated, but this toString()
call was not required so removed it.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
In the PR build there were some failed tests ( |
hbase-server/src/main/resources/hbase-webapps/master/procedures.jsp
Outdated
Show resolved
Hide resolved
hbase-server/src/main/resources/hbase-webapps/master/snapshot.jsp
Outdated
Show resolved
Hide resolved
hbase-server/src/main/resources/hbase-webapps/master/snapshotsStats.jsp
Outdated
Show resolved
Hide resolved
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.
replace org.apache.commons.lang3.StringEscapeUtils.escapeXml -> org.apache.commons.lang3.StringEscapeUtils.escapeXml10
@NihalJain thanks for the review and the proposal. 👍 As I mentioned above - since the whole |
Oh ok, in that case we may need to add commons text as a dependency right? Until now we have used |
5f5485c
to
67e6f75
Compare
IMO HBase already has more than enough dependencies, we should try to avoid adding more if we can. Is there a known security issue with the current xmlEscape ? |
Even if it's already coming from Hadoop, it still bloats the Hadoop-less HBase assembly. |
+1 on idea of avoiding new dependency. I too am skeptical about this new addition and needed another set of eyes to approve of this. Thanks for chiming in @stoty ! |
I suggest reverting the change that requires the new commons-text dependency, and keeping the rest of the cleanups, @PDavid . |
Unless it fixes a known security issue. |
Hi @NihalJain and @stotyű! Many thanks for your feedback. 👍 My motivation of adding commons text was that the used API ( But of course if you wish, we can keep using the deprecated API as today it is still there. |
Let's skip the commons-text dependency for now. |
d93981e
to
09cf7db
Compare
/** | ||
* Note: This method was taken from org.apache.hadoop.util.StringUtils.humanReadableInt(long). | ||
* Given an integer, return a string that is in an approximate, but human | ||
* readable format. | ||
* @param number the number to format | ||
* @return a human readable form of the integer | ||
*/ | ||
private static String humanReadableInt(long number) { | ||
return StringUtils.TraditionalBinaryPrefix.long2String(number, "", 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.
Should I maybe rather extract this method to a util class as it is now duplicated in these 2 JSP files?
Maybe it can be extracted to org.apache.hadoop.hbase.util.Strings
util class.
What do you think?
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 please. We have several instances of the deprecated method all over the code, we can re-use it for those cases as well. See https://github.com/search?q=repo%3Aapache%2Fhbase+StringUtils.humanReadableInt&type=code
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.
Agree
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.
Thanks, this should be done now.
OK, now as suggested I reverted the change that requires the new commons-text dependency. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This looks mostly good to me, my only problem that this does not match the JIRA description. |
@stoty thanks, this is a very good point. I started with the deprecated calls in the JSP-s but then @NihalJain proposed to also replace the same Should I maybe revert those changes? Or rename the Jira ticket? |
Update the ticket and commit description. |
8fc881e
to
e230e41
Compare
This comment has been minimized.
This comment has been minimized.
- Replaced the usage of the following deprecated methods: - java.net.URLEncoder.encode(String) -> java.net.URLEncoder.encode(String, Charset) - StringUtils.humanReadableInt(long) -> StringUtils.TraditionalBinaryPrefix.long2String(long, "", 1): For this a new static util method is introduced: org.apache.hadoop.hbase.util.Strings.humanReadableInt - org.apache.hadoop.fs.FileSystem.getLength(Path) -> getFileStatus(Path).getLen() - org.apache.hadoop.hbase.ServerName.getStartcode() -> org.apache.hadoop.hbase.ServerName.getStartCode() - Also removed unused imports in the touched JSP files.
e230e41
to
cc52e79
Compare
This comment has been minimized.
This comment has been minimized.
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |