Uploaded image for project: 'Pentaho Analysis - Mondrian'
  1. Pentaho Analysis - Mondrian
  2. MONDRIAN-620

Format strings which omit the "Nil" format can cause an array out of bounds exception.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Severity: None
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Notice:
      When an issue is open, the "Fix Version/s" field conveys a target, not necessarily a commitment. When an issue is closed, the "Fix Version/s" field conveys the version that the issue was fixed in.

      Description

      Mondrian supports a format string that follows a layout like this:

      #,##0;(#,##0);0

      Where the item to the left is the format for positive numbers, the format in the middle is negative, and the format to the right is Nil.

      I discovered recently that if you omit the Nil format string you can get an ArrayIndexOutOfBoundsException. The following unit test shows this

      public void testMissingNilFormat()

      { checkFormat(null, -0.02, "#,##0;(#,##0)"); }

      java.lang.ArrayIndexOutOfBoundsException: 2
      at mondrian.util.Format$AlternateFormat.format(Format.java:348)
      at mondrian.util.Format.format(Format.java:2432)
      at mondrian.util.Format.format(Format.java:2420)
      at mondrian.util.FormatTest.checkFormat(FormatTest.java:404)
      at mondrian.util.FormatTest.testSmallNumber(FormatTest.java:249)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)

        Attachments

          Activity

            People

            • Assignee:
              jhyde Julian Hyde (Inactive)
              Reporter:
              mkambol mkambol
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: