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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Cannot Reproduce
    • None
    • None
    • None
    • 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).

      Attachments

        Activity

          People

            maurizio.cucchiara Maurizio Cucchiara
            e011545 Kevin Biesbrock
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: