Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-3762

XWorkBasicConverter doConvertToCollection causes ClassCastException if an item cannot be converted

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.1.2
    • 2.3.3
    • Value Stack
    • 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.

      Attachments

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

        Activity

          People

            lukaszlenart Lukasz Lenart
            pelladi Pelladi Gabor
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: