Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8349883

Locale.LanguageRange.parse("-") throws ArrayIndexOutOfBoundsException

XMLWordPrintable

    • b11
    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      Passing the invalid string "-" to Locale.LanguageRange.parse results in an ArrayIndexOutOfBoundsException being thrown instead of the expected IllegalArgumentException.

      Method documentation says:
      throws IllegalArgumentException - if a language range or a weight found in the given ranges is ill-formed


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      java.util.Locale.LanguageRange.parse("-");


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      IllegalArgumentException thrown
      ACTUAL -
      java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0


      ---------- BEGIN SOURCE ----------
      public class Test {
      public static void main(String[] args) {
      java.util.Locale.LanguageRange.parse("-");
      }
      }
      ---------- END SOURCE ----------

            jlu Justin Lu
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: