mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8317246: Cleanup java.net.URLEncoder and URLDecoder use of file.encoding property
Reviewed-by: rriggs, naoto
This commit is contained in:
parent
b6a97c0780
commit
3bcfac18c3
2 changed files with 3 additions and 30 deletions
|
@ -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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,14 +34,13 @@ import java.nio.charset.CharsetEncoder;
|
||||||
import java.nio.charset.CoderResult;
|
import java.nio.charset.CoderResult;
|
||||||
import java.nio.charset.CodingErrorAction;
|
import java.nio.charset.CodingErrorAction;
|
||||||
import java.nio.charset.IllegalCharsetNameException;
|
import java.nio.charset.IllegalCharsetNameException;
|
||||||
import java.nio.charset.UnsupportedCharsetException ;
|
import java.nio.charset.UnsupportedCharsetException;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.HexFormat;
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue