[
https://issues.apache.org/jira/browse/MYFACES-4508?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17637318#comment-17637318
]
Volodymyr Siedlecki commented on MYFACES-4508:
----------------------------------------------
This was discovered in
{color:#e8912d}numConverterGetAsObjectParseIntOnlyTest{color}:
[https://github.com/jakartaee/faces/blob/3fae98234692ec16545a6d27cf36fabaeb883f9b/tck/old-tck/source/src/com/sun/ts/tests/jsf/api/jakarta_faces/convert/numberconverter/TestServlet.java#L573]
> Ignore ParsePosition when setParseIntegerOnly is true
> -----------------------------------------------------
>
> Key: MYFACES-4508
> URL: https://issues.apache.org/jira/browse/MYFACES-4508
> Project: MyFaces Core
> Issue Type: Bug
> Affects Versions: 2.3-next-M7, 4.0.0-RC2
> Reporter: Volodymyr Siedlecki
> Priority: Major
>
> 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:|https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/NumberFormat.html]
> 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.
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)