Uploaded image for project: 'Click'
  1. Click
  2. CLK-600

Page.getMessage( message, params) does not accept null for params

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 2.1.0
    • Fix Version/s: 2.1.0
    • Component/s: core
    • Labels:
      None

      Description

      Page.getMessage() method does not accept null as parameter for Object[] args while it should.

      Instead of this:
      content = getMessage("exception_" + ex.getErrorType() + "_message", ex.getParameters());

      I have to write code like this:
      if (ex.getParameters() != null)

      { content = getMessage("exception_" + ex.getErrorType() + "_message", ex.getParameters()); }

      else

      { content = getMessage("exception_" + ex.getErrorType() + "_message"); }

      The underlying mechanism, MessageFormat.format(String, Object[]) has no trouble handling null as args, so I don't see the reason to bomb out with an IllegalArgumentException("Null args parameter");

        Activity

        Hide
        medgar Malcolm Edgar added a comment -

        Fix checked in, thanks for the issue.

        Show
        medgar Malcolm Edgar added a comment - Fix checked in, thanks for the issue.
        Hide
        sabob Bob Schellink added a comment -

        MessageFormat#format takes a vararg as message arguments, so perhaps we could do the same with getMessage?

        public String getMessage(String name, Object... args)

        { String value = getMessage(name); return MessageFormat.format(value, args); }

        This way we only need a single getMessage method and can remove the other two.

        Show
        sabob Bob Schellink added a comment - MessageFormat#format takes a vararg as message arguments, so perhaps we could do the same with getMessage? public String getMessage(String name, Object... args) { String value = getMessage(name); return MessageFormat.format(value, args); } This way we only need a single getMessage method and can remove the other two.
        Hide
        sabob Bob Schellink added a comment -

        Will open a separate issue for introducing a varargs getMessages method.

        Show
        sabob Bob Schellink added a comment - Will open a separate issue for introducing a varargs getMessages method.

          People

          • Assignee:
            medgar Malcolm Edgar
            Reporter:
            surfman WarnerJan Veldhuis
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development