forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-49240][BUILD] Add
scalastyle
and checkstyle
rules to avoid…
… `URL` constructors ### What changes were proposed in this pull request? This PR aims to add `scalastyle` and `checkstyle` rules to avoid `URL` constructors. ### Why are the changes needed? The java.net.URL class does not itself encode or decode any URL components according to the escaping mechanism defined in RFC2396. So, from Java 20, all `URL` constructors are deprecated. We had better use better `URI` class. - https://bugs.openjdk.org/browse/JDK-8295949 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Pass the CIs with newly added rules. After this PR, there is only two exceptional instances in `JettyUtils.scala` and `UISuite.scala`. - `JettyUtils` is tricky instance - UISuite test case is supposed to add bad URL which URI prevents with `java.net.URISyntaxException`. This is an example why `URI` is better. In this PR, we keep the old, URL class, to keep the test coverage. ``` $ git grep -C1 'new URL(' core/src/main/scala/org/apache/spark/ui/JettyUtils.scala- // scalastyle:off URLConstructor core/src/main/scala/org/apache/spark/ui/JettyUtils.scala: val newUrl = new URL(requestURL, prefixedDestPath).toString core/src/main/scala/org/apache/spark/ui/JettyUtils.scala- // scalastyle:on URLConstructor -- core/src/test/scala/org/apache/spark/ui/UISuite.scala- // scalastyle:off URLConstructor core/src/test/scala/org/apache/spark/ui/UISuite.scala: val badRequest = new URL( core/src/test/scala/org/apache/spark/ui/UISuite.scala- s"http://$localhost:${serverInfo.boundPort}$path/root?bypass&invalid<=foo") ``` ### Was this patch authored or co-authored using generative AI tooling? No. Closes apache#47762 from dongjoon-hyun/SPARK-49240. Authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: yangjie01 <[email protected]>
- Loading branch information
1 parent
a0fc398
commit 0c24ae1
Showing
20 changed files
with
95 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.