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

Refine null locale processing of ctor/factory methods in `Date/DecimalFormatSymbols`

XMLWordPrintable

    • master
    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      DateFormatSymbols(locale) doesn't check for null, causing an NPE when finding a null key in a map.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      MissingResourceException – if the resources for the specified locale cannot be found or cannot be loaded.
      ACTUAL -
      Exception in thread "main" java.lang.NullPointerException: Cannot invoke "Object.hashCode()" because "key" is null
      at java.base/java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:948)
      at java.base/java.text.DateFormatSymbols.initializeData(DateFormatSymbols.java:725)
      at java.base/java.text.DateFormatSymbols.<init>(DateFormatSymbols.java:151)

      ---------- BEGIN SOURCE ----------
          public static void main(String[] args)
          {
              DateFormatSymbols defaultSymbols = new DateFormatSymbols(null);
          }
      ---------- END SOURCE ----------

            naoto Naoto Sato
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: