Struts 2
  1. Struts 2
  2. WW-3732

XWorkBasicConverter with BigDecimal; trim input as in extended class: DefaultTypeConverter

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      When a value for a parameter of type `BigDecimal` is converted by `XWorkBasicConverter` (this is default Struts2 behavior), a failure occurs when there is a space in the value. The parent to `XWorkBasicConverter`, `DefaultTypeConverter`, has a `stringValue` method that could could be used instead of immediately casting to a String, e.g., `new BigDecimal((String) value)`, which is what ultimately appears to cause a `NumberFormatException` to be thrown from the `BigDecimal` constructor when there is a space in the value.

      For example, in version 2.2.3.1, the following lines could be changed as indicated:
      403: return new BigDecimal(stringValue(value, true));
      405: return new BigInteger(stringValue(value, true));
      408: String stringValue = stringValue(value, true);
      414: String stringValue = stringValue(value, true);

      In fact, at the end of the doConvertToNumber method (where the previous lines reside), as a catch-all, the parameters are passed to the DefaultTypeConverter's `convertValue` method which calls the `bigDecValue` method which calls the `stringValue` method (when all the conditionals align).

        Activity

        Kevin Biesbrock created issue -
        Lukasz Lenart made changes -
        Field Original Value New Value
        Fix Version/s 2.5 [ 12319158 ]
        Lukasz Lenart made changes -
        Fix Version/s 2.3.x [ 12319176 ]
        Fix Version/s 3.0 [ 12319158 ]
        Lukasz Lenart made changes -
        Fix Version/s 2.3.16 [ 12324546 ]
        Fix Version/s 2.3.x [ 12319176 ]
        Maurizio Cucchiara made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Maurizio Cucchiara [ maurizio.cucchiara ]
        Fix Version/s 2.3.16 [ 12324546 ]
        Resolution Fixed [ 1 ]
        Maurizio Cucchiara made changes -
        Resolution Fixed [ 1 ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        Maurizio Cucchiara made changes -
        Status Reopened [ 4 ] Closed [ 6 ]
        Resolution Cannot Reproduce [ 5 ]

          People

          • Assignee:
            Maurizio Cucchiara
            Reporter:
            Kevin Biesbrock
          • Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development