Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-4508

Handle ParsePosition when setParseIntegerOnly is true

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3-next-M7, 4.0.0-RC2
    • 2.3-next-M8, 4.0.0-RC3
    • None
    • None

    Description

      Background Issue: https://issues.apache.org/jira/browse/MYFACES-3196

      In the issue linked above, MyFaces was updated to check the ParsePosition after parsing. If the ParsePosition index differed from the length of the input, then that meant part of the string was not iterated though and there was likely a problem.

      However this can become another issue when setParseIntegerOnly is set to true because it leaves the index just after the decimal point. See the example in the text.

      The documentation state:

      setParseIntegerOnly : only affects parsing, e.g. if true, "3456.78" → 3456 (and leaves the parse position just after index 6) if false, "3456.78" → 3456.78 (and leaves the parse position just after index 8) This is independent of formatting. If you want to not show a decimal point where there might be no digits after the decimal point, use setDecimalSeparatorAlwaysShown. 

       

      This can unnecessarily throw a ParseException here: https://github.com/apache/myfaces/blob/e74edfdbfb0b666e7b6b065dfce2c81899ea1cc7/api/src/main/java/jakarta/faces/convert/NumberConverter.java#L204

      While we can check for a decimal separator, but it differs between the various locales. I think it best to ignore the ParsePosition here when setParseIntegerOnly is true.

       

       

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            volosied Volodymyr Siedlecki
            volosied Volodymyr Siedlecki
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment