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

View file

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