I just entered MONDRIAN-620 for the following issue. Mondrian supports a format string that follows a layout like this: <br><br> #,##0;(#,##0);0<br><br>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.<br>
<br>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):<br><br><br>
public void testMissingNilFormat()
<br>
{
<br>
checkFormat(null, -0.02, "#,##0;(#,##0)");
<br>
}
<br>
<br><br>java.lang.ArrayIndexOutOfBoundsException: 2<br> at mondrian.util.Format$AlternateFormat.format(Format.java:348)<br> at mondrian.util.Format.format(Format.java:2432)<br> at mondrian.util.Format.format(Format.java:2420)<br>
at mondrian.util.FormatTest.checkFormat(FormatTest.java:404)<br> at mondrian.util.FormatTest.testSmallNumber(FormatTest.java:249)<br> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br>
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br> at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)<br> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br> at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)<br>
<br>A possible solution would be to use a default format string if none is specified. Does that sound like a reasonable fix?<br>