Struts 2
  1. Struts 2
  2. WW-3762

XWorkBasicConverter doConvertToCollection causes ClassCastException if an item cannot be converted

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.1.2
    • Fix Version/s: 2.3.3
    • Component/s: Value Stack
    • Labels:
    • Flags:
      Patch

      Description

      My action has a property of type List<Integer> (same for other non-string types). The action will later iterate over this property, and it gets a ClassCastException, because the list (of type List<Integer>) contains a String.

      It is because XWorkBasicConverter.doConvertToCollection() converts the input string array into an integer list. But if the input coming from the browser contains a value that cannot be converted to a string, then the string "ognl.NoConversionPossible" is put into the list. It is wrong, we should pay attention to the type of the list.

      I have attached a patch that does not put elements into the list that cannot be converted.
      I have also attached a file that contains a simple example for this bug.

      1. example.txt
        0.7 kB
        Pelladi Gabor
      2. WW-3762.diff
        2 kB
        Pelladi Gabor
      3. WW-3762.patch
        61 kB
        Lukasz Lenart

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Lukasz Lenart
            Reporter:
            Pelladi Gabor
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development