mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-25 22:04:51 +02:00
8349883: Locale.LanguageRange.parse("-") throws ArrayIndexOutOfBoundsException
Reviewed-by: naoto
This commit is contained in:
parent
3e7acfac48
commit
3741c980b8
3 changed files with 71 additions and 77 deletions
|
@ -3266,9 +3266,7 @@ public final class Locale implements Cloneable, Serializable {
|
|||
* or greater than {@code MAX_WEIGHT}
|
||||
*/
|
||||
public LanguageRange(String range, double weight) {
|
||||
if (range == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
Objects.requireNonNull(range);
|
||||
if (weight < MIN_WEIGHT || weight > MAX_WEIGHT) {
|
||||
throw new IllegalArgumentException("weight=" + weight);
|
||||
}
|
||||
|
@ -3278,8 +3276,8 @@ public final class Locale implements Cloneable, Serializable {
|
|||
// Do syntax check.
|
||||
boolean isIllFormed = false;
|
||||
String[] subtags = range.split("-");
|
||||
if (isSubtagIllFormed(subtags[0], true)
|
||||
|| range.endsWith("-")) {
|
||||
if (range.endsWith("-") ||
|
||||
isSubtagIllFormed(subtags[0], true)) {
|
||||
isIllFormed = true;
|
||||
} else {
|
||||
for (int i = 1; i < subtags.length; i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue