CommonFns.formatNumber() doesn't handle null as javadoc mentions

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major
    • 10.0.0
    • Affects Version/s: 9.6.4
    • Component/s: None
    • Security Level: Jimmy
    • None
    • None

      Steps to Reproduce

      <?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
      <zk>
          <label value="${c:formatNumber(null, '$ ###,###,###.00')}" />
      </zk>
      

      Current Result

      java.lang.IllegalArgumentException: Cannot format given Object as a Number
      java.base/java.text.DecimalFormat.format(DecimalFormat.java:518)
      java.base/java.text.Format.format(Format.java:158)
      org.zkoss.xel.fn.CommonFns.formatNumber(CommonFns.java:491)
      org.zkoss.xel.fn.CommonFns.formatNumber(CommonFns.java:429)

      Expected Result

      empty string.

      Debug Information

      • its javadoc mentioned:

        ... If null, an empty string is returned.

      • Since it's called on a zul, it's better to return an empty string instead of throwing a runtime exception. An EL expression also evaluate a null as an empty string, no exception.

      Workaround

      null check

            Assignee:
            jamson
            Reporter:
            hawk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: