Uploaded image for project: 'Seam 2'
  1. Seam 2
  2. JBSEAM-624

Interpolator class does not handle null argument arrays and arrays with only one argument

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 1.1.1.GA
    • Component/s: None
    • Labels:
      None
    • Workaround Description:
      Hide

      1. If you want to use a params array from somewhere else in your application as a parameter for FacesMessages.addFromResourceBundle(String, Object...) make sure to use FacesMessages.addFromResourceBundle("some_key") if your array is null.

      2. If you only have a single parameters in your array just add a dummy at the second position.

      Show
      1. If you want to use a params array from somewhere else in your application as a parameter for FacesMessages.addFromResourceBundle(String, Object...) make sure to use FacesMessages.addFromResourceBundle("some_key") if your array is null. 2. If you only have a single parameters in your array just add a dummy at the second position.

      Description

      In method Interpolator.interpolate(String, Object...) are two possible bugs:

      1. If the params arrays is null the method throws a NullPointerException. The array originally comes from the method FacesMessages.addFromResourceBundle(String, Object...). If the method is called without arguments, like addFromResourceBundle("some_key") then Java will automatically create an array with length zero and everything works fine. But if the application get this array from somewhere else, and it is null, the problem begins.

      2. If there is only one element in the array the params will not be formatted to the message at all. This is because of the line:

      if ( params.length>1 && string.indexOf('{')>=0 ) ...

      should be:

      if ( params.length>0 && string.indexOf('{')>=0 ) ...

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                gavin.king Gavin King
                Reporter:
                f.ulbricht Frank Ulbricht
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: