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

Reviewed-by: rriggs, naoto
This commit is contained in:
Glavo 2023-10-03 10:34:12 +00:00 committed by Claes Redestad
parent b6a97c0780
commit 3bcfac18c3
2 changed files with 3 additions and 30 deletions

View file

@ -25,8 +25,6 @@
package java.net; package java.net;
import jdk.internal.util.StaticProperty;
import java.io.*; import java.io.*;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException; import java.nio.charset.IllegalCharsetNameException;
@ -90,9 +88,6 @@ public class URLDecoder {
*/ */
private URLDecoder() {} private URLDecoder() {}
// The default charset
private static final String DEFAULT_ENCODING_NAME = StaticProperty.fileEncoding();
/** /**
* Decodes a {@code x-www-form-urlencoded} string. * Decodes a {@code x-www-form-urlencoded} string.
* The default charset is used to determine what characters * The default charset is used to determine what characters
@ -106,16 +101,7 @@ public class URLDecoder {
*/ */
@Deprecated @Deprecated
public static String decode(String s) { public static String decode(String s) {
return decode(s, Charset.defaultCharset());
String str = null;
try {
str = decode(s, DEFAULT_ENCODING_NAME);
} catch (UnsupportedEncodingException e) {
// The system should always have the default charset
}
return str;
} }
/** /**

View file

@ -41,7 +41,6 @@ import java.util.HexFormat;
import java.util.function.IntPredicate; import java.util.function.IntPredicate;
import jdk.internal.util.ImmutableBitSetPredicate; import jdk.internal.util.ImmutableBitSetPredicate;
import jdk.internal.util.StaticProperty;
/** /**
* Utility class for HTML form encoding. This class contains static methods * Utility class for HTML form encoding. This class contains static methods
@ -87,7 +86,6 @@ import jdk.internal.util.StaticProperty;
*/ */
public class URLEncoder { public class URLEncoder {
private static final IntPredicate DONT_NEED_ENCODING; private static final IntPredicate DONT_NEED_ENCODING;
private static final String DEFAULT_ENCODING_NAME;
static { static {
@ -139,8 +137,6 @@ public class URLEncoder {
bitSet.set('*'); bitSet.set('*');
DONT_NEED_ENCODING = ImmutableBitSetPredicate.of(bitSet); DONT_NEED_ENCODING = ImmutableBitSetPredicate.of(bitSet);
DEFAULT_ENCODING_NAME = StaticProperty.fileEncoding();
} }
/** /**
@ -161,16 +157,7 @@ public class URLEncoder {
*/ */
@Deprecated @Deprecated
public static String encode(String s) { public static String encode(String s) {
return encode(s, Charset.defaultCharset());
String str = null;
try {
str = encode(s, DEFAULT_ENCODING_NAME);
} catch (UnsupportedEncodingException e) {
// The system should always have the default charset
}
return str;
} }
/** /**