RFR: 8317246: Cleanup java.net.URLEncoder and URLDecoder use of file.encoding property

Glavo duke at openjdk.org
Thu Sep 28 18:13:08 UTC 2023


`DEFAULT_ENCODING_NAME ` in `URLEncoder` and `URLDecoder` can be replaced with `Charset.defaultCharset()`, which removes unnecessary static fields and avoid looking up charset when calling `URLDecoder.decode(String)` and `URLEncoder.encode(String)`.

This PR is trivial, since `Charset.defaultCharset()` is also initialized with `StaticProperty.fileEncoding()`, this causes no change in behavior. 

Moreover, the javadoc of `URLDecoder.decode(String)` and `URLEncoder.encode(String)` say that they use the default charset, so this change is semantically consistent with the documentation.

-------------

Commit messages:
 - Merge branch 'master' into dflt-enc-name
 - Merge branch 'master' into dflt-enc-name
 - Remove DEFAULT_ENCODING_NAME from URLEncoder and URLDecoder

Changes: https://git.openjdk.org/jdk/pull/15353/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=15353&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8317246
  Stats: 30 lines in 2 files changed: 0 ins; 27 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/15353.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/15353/head:pull/15353

PR: https://git.openjdk.org/jdk/pull/15353


More information about the net-dev mailing list