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

HBASE-29026 Replace some deprecated calls #6585

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PDavid
Copy link
Contributor

@PDavid PDavid commented Jan 8, 2025

  • 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())
Copy link
Contributor Author

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.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@PDavid
Copy link
Contributor Author

PDavid commented Jan 9, 2025

In the PR build there were some failed tests (TestVerifyBucketCacheFile) but to me they look unrelated.

@PDavid PDavid marked this pull request as ready for review January 9, 2025 07:41
Copy link
Contributor

@NihalJain NihalJain left a 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

@PDavid
Copy link
Contributor Author

PDavid commented Jan 9, 2025

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 org.apache.commons.lang3.StringEscapeUtils class is deprecated I would rather replace it with the commons-text class.

@NihalJain
Copy link
Contributor

NihalJain commented Jan 9, 2025

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 org.apache.commons.lang3.StringEscapeUtils class is deprecated I would rather replace it with the commons-text class.

Oh ok, in that case we may need to add commons text as a dependency right? Until now we have used org.apache.commons.text* in only 2 test classes.

@PDavid PDavid force-pushed the HBASE-29026-jsp-deprecated-calls branch from 5f5485c to 67e6f75 Compare January 9, 2025 14:35
pom.xml Outdated Show resolved Hide resolved
@stoty
Copy link
Contributor

stoty commented Jan 16, 2025

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 ?
Is there something in another existing dependency that we could use ?

@stoty
Copy link
Contributor

stoty commented Jan 16, 2025

Even if it's already coming from Hadoop, it still bloats the Hadoop-less HBase assembly.

@NihalJain
Copy link
Contributor

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 ? Is there something in another existing dependency that we could use ?

+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 !

@stoty
Copy link
Contributor

stoty commented Jan 17, 2025

I suggest reverting the change that requires the new commons-text dependency, and keeping the rest of the cleanups, @PDavid .

@stoty
Copy link
Contributor

stoty commented Jan 17, 2025

Unless it fixes a known security issue.

@PDavid
Copy link
Contributor Author

PDavid commented Jan 20, 2025

Hi @NihalJain and @stotyű!

Many thanks for your feedback. 👍

My motivation of adding commons text was that the used API (org.apache.commons.lang3.StringEscapeUtils) was moved to commons text and it is marked as deprecated in commons lang. I think in a future version the deprecated API will be removed. That's why it is better to not depend on it in my opinion. Commons text is a small Apache library which does not have any other dependencies.

But of course if you wish, we can keep using the deprecated API as today it is still there.

@stoty
Copy link
Contributor

stoty commented Jan 20, 2025

Let's skip the commons-text dependency for now.

@PDavid PDavid force-pushed the HBASE-29026-jsp-deprecated-calls branch from d93981e to 09cf7db Compare January 20, 2025 10:34
Comment on lines 36 to 45
/**
* 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);
}
Copy link
Contributor Author

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?

Copy link
Contributor

@NihalJain NihalJain Jan 20, 2025

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree

Copy link
Contributor Author

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.

@PDavid
Copy link
Contributor Author

PDavid commented Jan 20, 2025

OK, now as suggested I reverted the change that requires the new commons-text dependency.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@PDavid PDavid requested a review from stoty January 21, 2025 07:54
@stoty
Copy link
Contributor

stoty commented Jan 22, 2025

This looks mostly good to me, my only problem that this does not match the JIRA description.
At least half of the changes are not in JSPs.

@PDavid
Copy link
Contributor Author

PDavid commented Jan 22, 2025

This looks mostly good to me, my only problem that this does not match the JIRA description. At least half of the changes are not in JSPs.

@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 org.apache.hadoop.util.StringUtils.humanReadableInt(long) call in all places.
So eventually now we have more changes not in the JSP-s. 🙈

Should I maybe revert those changes? Or rename the Jira ticket?
What do you all think?

@stoty
Copy link
Contributor

stoty commented Jan 22, 2025

Update the ticket and commit description.

@PDavid PDavid changed the title HBASE-29026 Replace deprecated calls in JSP files HBASE-29026 Replace some deprecated calls Jan 22, 2025
@PDavid PDavid force-pushed the HBASE-29026-jsp-deprecated-calls branch from 8fc881e to e230e41 Compare January 22, 2025 11:03
@Apache-HBase

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.
@PDavid PDavid force-pushed the HBASE-29026-jsp-deprecated-calls branch from e230e41 to cc52e79 Compare January 22, 2025 12:30
@Apache-HBase

This comment has been minimized.

@Apache-HBase
Copy link

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 29s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 hbaseanti 0m 0s Patch does not have any anti-patterns.
_ master Compile Tests _
+0 🆗 mvndep 0m 11s Maven dependency ordering for branch
+1 💚 mvninstall 2m 52s master passed
+1 💚 compile 4m 43s master passed
+1 💚 checkstyle 1m 5s master passed
+1 💚 spotbugs 2m 50s master passed
+1 💚 spotless 0m 41s branch has no errors when running spotless:check.
_ Patch Compile Tests _
+0 🆗 mvndep 0m 11s Maven dependency ordering for patch
+1 💚 mvninstall 2m 49s the patch passed
+1 💚 compile 4m 46s the patch passed
+1 💚 javac 4m 46s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 1m 8s the patch passed
+1 💚 spotbugs 3m 27s the patch passed
+1 💚 hadoopcheck 11m 0s Patch does not cause any errors with Hadoop 3.3.6 3.4.0.
+1 💚 spotless 0m 43s patch has no errors when running spotless:check.
_ Other Tests _
+1 💚 asflicense 0m 33s The patch does not generate ASF License warnings.
45m 7s
Subsystem Report/Notes
Docker ClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6585/6/artifact/yetus-general-check/output/Dockerfile
GITHUB PR #6585
Optional Tests dupname asflicense javac spotbugs checkstyle codespell detsecrets compile hadoopcheck hbaseanti spotless
uname Linux 50ae3af7d97e 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/hbase-personality.sh
git revision master / cc52e79
Default Java Eclipse Adoptium-17.0.11+9
Max. process+thread count 85 (vs. ulimit of 30000)
modules C: hbase-common hbase-server hbase-mapreduce hbase-diagnostics U: .
Console output https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6585/6/console
versions git=2.34.1 maven=3.9.8 spotbugs=4.7.3
Powered by Apache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase
Copy link

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 35s Docker mode activated.
-0 ⚠️ yetus 0m 3s Unprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --author-ignore-list --blanks-eol-ignore-file --blanks-tabs-ignore-file --quick-hadoopcheck
_ Prechecks _
_ master Compile Tests _
+0 🆗 mvndep 0m 15s Maven dependency ordering for branch
+1 💚 mvninstall 3m 33s master passed
+1 💚 compile 2m 11s master passed
+1 💚 javadoc 1m 21s master passed
+1 💚 shadedjars 6m 5s branch has no errors when building our shaded downstream artifacts.
_ Patch Compile Tests _
+0 🆗 mvndep 0m 13s Maven dependency ordering for patch
+1 💚 mvninstall 2m 53s the patch passed
+1 💚 compile 1m 50s the patch passed
+1 💚 javac 1m 50s the patch passed
+1 💚 javadoc 1m 8s the patch passed
+1 💚 shadedjars 5m 45s patch has no errors when building our shaded downstream artifacts.
_ Other Tests _
+1 💚 unit 2m 15s hbase-common in the patch passed.
-1 ❌ unit 210m 57s /patch-unit-hbase-server.txt hbase-server in the patch failed.
+1 💚 unit 19m 51s hbase-mapreduce in the patch passed.
+1 💚 unit 4m 49s hbase-diagnostics in the patch passed.
269m 2s
Subsystem Report/Notes
Docker ClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6585/6/artifact/yetus-jdk17-hadoop3-check/output/Dockerfile
GITHUB PR #6585
Optional Tests javac javadoc unit compile shadedjars
uname Linux 7d1224dd353b 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/hbase-personality.sh
git revision master / cc52e79
Default Java Eclipse Adoptium-17.0.11+9
Test Results https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6585/6/testReport/
Max. process+thread count 5215 (vs. ulimit of 30000)
modules C: hbase-common hbase-server hbase-mapreduce hbase-diagnostics U: .
Console output https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6585/6/console
versions git=2.34.1 maven=3.9.8
Powered by Apache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants