Harmony
  1. Harmony
  2. HARMONY-424

[classlib][text] NullPointerException in java.text.DecimalFormat.getCurrency()

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Classlib
    • Labels:
      None
    • Environment:
      WIN with Russian defaults

      Description

      Consider the following code:

      System.out.println("Locale " + Locale.getDefault());
      System.out.println("Default " + Currency.getInstance(Locale.getDefault()));
      DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance();
      System.out.println("Currency "+format.getCurrency());

      It produses (on computer with Russian defaults):

      RI output:
      Locale ru_RU
      Default RUR
      Currency RUR

      Harmony output:
      Locale ru_RU
      Default RUR
      ?????????????? ???????? ? ???? "main" java.lang.NullPointerException
      at java.text.DecimalFormat.getCurrency(DecimalFormat.java:271)
      at test.main(test.java:10)

      org.apache.harmony.tests.java.text.DecimalFormatTest failed due this reason.
      Looks like a bug in icu4 lib (used in java.text.DecimalFormat).

        Activity

        Mikhail Loenko made changes -
        Summary NullPointerException in java.text.DecimalFormat.getCurrency() [classlib][text] NullPointerException in java.text.DecimalFormat.getCurrency()
        Hide
        Boris Kuznetsov added a comment -

        According to DecimalFormat.getCurrency() spec.:
        "The currency is obtained by calling DecimalFormatSymbols.getCurrency on this number format's symbols.

        DecimalFormatSymbols.getCurrency says:
        "May be null if the currency symbol attribute was previously set to a value that's not a valid ISO 4217 currency code."

        So, DecimalFormat.getCurrency() should return null for invalid ISO 4217 currency codes only .

        Show
        Boris Kuznetsov added a comment - According to DecimalFormat.getCurrency() spec.: "The currency is obtained by calling DecimalFormatSymbols.getCurrency on this number format's symbols. DecimalFormatSymbols.getCurrency says: "May be null if the currency symbol attribute was previously set to a value that's not a valid ISO 4217 currency code." So, DecimalFormat.getCurrency() should return null for invalid ISO 4217 currency codes only .
        Hide
        Andrey Pavlenko added a comment -

        This issue is seems to be fixed in rev 404992. Now method DecimalFormat.getCurrency() returns null if the currency is unknown.
        I think the issue should be closed.

        Show
        Andrey Pavlenko added a comment - This issue is seems to be fixed in rev 404992. Now method DecimalFormat.getCurrency() returns null if the currency is unknown. I think the issue should be closed.
        Stepan Mishura made changes -
        Field Original Value New Value
        Component/s Classlib [ 12310560 ]
        Boris Kuznetsov created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            Boris Kuznetsov
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development