-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LANG-1695: NumberUtils::isParseable does not recognise numbers ending in dot #1071
Conversation
…al point and it is at the end of the input, is treated as a valid number
Codecov Report
@@ Coverage Diff @@
## master #1071 +/- ##
============================================
- Coverage 92.13% 92.13% -0.01%
Complexity 7504 7504
============================================
Files 195 195
Lines 15722 15720 -2
Branches 2897 2896 -1
============================================
- Hits 14486 14483 -3
Misses 665 665
- Partials 571 572 +1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@orionlibs Would you please reply in the Jira ticket to the comment https://issues.apache.org/jira/browse/LANG-1695?focusedCommentId=17709278&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-17709278 We really need to make sure we are not creating trouble for ourselves ;-) |
@garydgregory I am new to open source contribution and a week ago I started with Apache. I applied for a JIRA account, but I was denied one (with no reason given). So, I cannot login to JIRA. Here is the email from apache: The following reason was given: If you wish to appeal this decision, you may do so either directly with the |
@garydgregory also there are many many open tickets in JIRA for many projects that have actually been completed, but they are still open, with no assignees or comments or anything. |
What user name and real name did you use in the application? I'll see if I can find the application and rejection in the archives. |
@garydgregory I used this page |
@orionlibs |
thank you Gary. I just registered again for JIRA with the
email = ***@***.***
username = dimitrios.efthymiou
…On Mon, 3 Jul 2023 at 01:40, Gary Gregory ***@***.***> wrote:
@garydgregory <https://github.com/garydgregory> I am new to open source
contribution and a week ago I started with Apache. I applied for a JIRA
account, but I was denied one (with no reason given). So, I cannot login to
JIRA. Here is the email from apache: We regret to inform you that, upon
reviewing your request for a new Jira account connected with The Apache
Software Foundation, the commons project has chosen to deny the request. We
therefore will not create the Jira account.
The following reason was given: No reason given.
If you wish to appeal this decision, you may do so either directly with
the commons project, or by contacting the ASF Infrastructure team at:
***@***.***
@orionlibs <https://github.com/orionlibs>
Please apply again for a Jira account, I'll watch for it.
—
Reply to this email directly, view it on GitHub
<#1071 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABGQOMN5ITPI66OJCP5XUBTXOIIIVANCNFSM6AAAAAAZZBH2WU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@@ -918,7 +918,8 @@ public void testIsParsable() { | |||
assertFalse(NumberUtils.isParsable("pendro")); | |||
assertFalse(NumberUtils.isParsable("64, 2")); | |||
assertFalse(NumberUtils.isParsable("64.2.2")); | |||
assertFalse(NumberUtils.isParsable("64.")); | |||
assertTrue(NumberUtils.isParsable("64.")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a test that 64.. is false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elharo sorry. My understanding of the ticket is that 64. is true i.e. parseable and valid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- is valid but 64.. (two periods) is not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right. I added a test for it
…to LANG-1695-NumberUtils-isParseable-does-not-recognise-values-such-as-2-dot
@@ -1776,7 +1773,7 @@ private static boolean withDecimalsParsing(final String str, final int beginIdx) | |||
if (decimalPoints > 1) { | |||
return false; | |||
} | |||
if (!isDecimalPoint && !Character.isDigit(str.charAt(i))) { | |||
if (!isDecimalPoint && !Character.isDigit(str.charAt(i)) && !(i == str.length() - 1 && str.charAt(i) == '.')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens in countries that flip the meaning of the comma and period?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps there could be another method that takes a Locale object. Otherwise, I don't think the current parser should concern itself with it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per current Javadoc "Parsable numbers include those Strings understood by Integer#parseInt(String), Long#parseLong(String), Float#parseFloat(String)} or Double#parseDouble(String)."
If those methods don't worry about countries that flip the meaning of the comma and period, we shouldn't do it here. That would be a breaking behavior change.
As to another method that uses Locales, that's in java.util so outside the advertised scope for commons-lang.
@@ -1776,7 +1773,7 @@ private static boolean withDecimalsParsing(final String str, final int beginIdx) | |||
if (decimalPoints > 1) { | |||
return false; | |||
} | |||
if (!isDecimalPoint && !Character.isDigit(str.charAt(i))) { | |||
if (!isDecimalPoint && !Character.isDigit(str.charAt(i)) && !(i == str.length() - 1 && str.charAt(i) == '.')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per current Javadoc "Parsable numbers include those Strings understood by Integer#parseInt(String), Long#parseLong(String), Float#parseFloat(String)} or Double#parseDouble(String)."
If those methods don't worry about countries that flip the meaning of the comma and period, we shouldn't do it here. That would be a breaking behavior change.
As to another method that uses Locales, that's in java.util so outside the advertised scope for commons-lang.
To make things more complicated, in the French locale a non-breaking space can be used to separate some items. I can't recall the details now but it's yet another thing to lookout for. |
The more I think about this, the more I'm convinced we should not account for localization. This method is not for the purpose of determining whether a string is plausibly a number. Its purpose is to return true or false depending on whether the string can be parsed by one of the java.lang.Number classes. Those classes don't consider localization, so this one shouldn't either. |
@elharo |
One purpose of this method is precisely to avoid using exceptions for flow control. |
this PR is still open after half a year |
LANG-1695 allowed for a number (positive or negative) that has only one decimal point and it is at the end of the input, is treated as a valid number