changeset 9899:2d7287eae0ad

8042360: Subtag syntax check is incomplete in Locale.LanguageRange Reviewed-by: naoto, okutsu
author peytoia
date Thu, 08 May 2014 08:22:25 +0900
parents 1811177bdbc6
children 851b1ddcdfb2
files src/share/classes/java/util/Locale.java test/java/util/Locale/Bug7069824.java
diffstat 2 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/Locale.java	Wed May 07 11:45:31 2014 -0700
+++ b/src/share/classes/java/util/Locale.java	Thu May 08 08:22:25 2014 +0900
@@ -2904,8 +2904,8 @@
                 for (int i = 1; i < subtags.length; i++) {
                     if (isSubtagIllFormed(subtags[i], false)) {
                         isIllFormed = true;
+                        break;
                     }
-                    break;
                 }
             }
             if (isIllFormed) {
--- a/test/java/util/Locale/Bug7069824.java	Wed May 07 11:45:31 2014 -0700
+++ b/test/java/util/Locale/Bug7069824.java	Thu May 08 08:22:25 2014 +0900
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 7069824
+ * @bug 7069824 8042360
  * @summary Verify implementation for Locale matching.
  * @run main Bug7069824
  */
@@ -91,6 +91,17 @@
         String range;
         double weight;
 
+        // Testcase for 8042360
+        range = "en-Latn-1234567890";
+        try {
+            lr = new LanguageRange(range);
+            error = true;
+            System.err.println("    IAE should be thrown for LanguageRange("
+                + range + ").");
+        }
+        catch (IllegalArgumentException ex) {
+        }
+
         range = null;
         try {
             lr = new LanguageRange(range);