[Mondrian] MONDRIAN-620: Incomplete format string
Matt Campbell
mkambol at gmail.com
Tue Sep 15 14:32:03 EDT 2009
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/f9a90374/attachment.html
More information about the Mondrian
mailing list