NanoContainer
  1. NanoContainer
  2. NANO-59

Property setting through ognl shouldn't use Arrays.asList()

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0-beta-1
    • Component/s: nanowar
    • Labels:
      None
    • Environment:
      Tomcat 5.0.19, ognl 2.5.1
    • Number of attachments :
      0

      Description

      A HttpServletRequest has the URI keywords as keys, and String[] as values. I don't understand the intention of setPropertiesWithOgnl():

      Object value = parameterMap.get(parameterKey);
      if (value instanceof String[])

      { value = Arrays.asList((String[]) value); }

      try

      { Ognl.setValue(parameterKey, action, value); }

      catch (OgnlException e)

      { e.printStackTrace(); throw new ServletException(e); }

      Why convert to Arrays.asList()? I did a test with Ognl standalone. It can match String[] as input, for a String[] property. With the current code, it will yield:

      java.lang.NoSuchMethodException: setNumber(java.util.Arrays$ArrayList)
      at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:551)
      ...

      Where it doesn't match the internal ArrayList used by Arrays.asList().

        Activity

        Hide
        Aslak Hellesøy added a comment -

        Fixed. Both arrays and lists are supported now. (First try array, if it fails try list).

        Show
        Aslak Hellesøy added a comment - Fixed. Both arrays and lists are supported now. (First try array, if it fails try list).
        Aslak Hellesøy made changes -
        Field Original Value New Value
        Resolution Fixed [ 1 ]
        Fix Version/s 1.0-beta-1 [ 10147 ]
        Status Open [ 1 ] Closed [ 6 ]
        Assignee Aslak Hellesoy [ rinkrank ]

          People

          • Assignee:
            Aslak Hellesøy
            Reporter:
            Miguel Paraz
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: