[Mondrian] MONDRIAN-620: Incomplete format string

Julian Hyde jhyde at pentaho.com
Tue Sep 15 22:52:08 EDT 2009


Matt,
 
See my comments on the bug.
 
http://jira.pentaho.com/browse/MONDRIAN-620
 
Julian


  _____  

From: mondrian-bounces at pentaho.org [mailto:mondrian-bounces at pentaho.org] On
Behalf Of Matt Campbell
Sent: Tuesday, September 15, 2009 11:32 AM
To: Mondrian developer mailing list
Subject: [Mondrian] MONDRIAN-620: Incomplete format string


I just entered MONDRIAN-620 for the following issue.  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 (it uses
checkFormat() from FormatTest):


 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)

A possible solution would be to use a default format string if none is
specified.  Does that sound like a reasonable fix?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pentaho.org/pipermail/mondrian/attachments/20090915/219753ab/attachment.html 


More information about the Mondrian mailing list