sebbASF commented on code in PR #394:
URL: https://github.com/apache/commons-validator/pull/394#discussion_r3380061369
##########
src/main/java/org/apache/commons/validator/routines/BigIntegerValidator.java:
##########
@@ -157,7 +158,12 @@ public boolean minValue(final BigInteger value, final long
min) {
*/
@Override
protected Object processParsedValue(final Object value, final Format
formatter) {
- return BigInteger.valueOf(((Number) value).longValue());
+ // A value that fits in a long is parsed as a Long; anything larger
comes back as a
+ // Double, whose longValue() saturates at Long.MAX_VALUE and loses the
magnitude.
+ if (value instanceof Long) {
+ return BigInteger.valueOf(((Long) value).longValue());
+ }
+ return new BigDecimal(value.toString()).toBigInteger();
Review Comment:
According to the Javadoc, processParsedValue always returns a BigInteger
##########
src/main/java/org/apache/commons/validator/routines/BigIntegerValidator.java:
##########
@@ -157,7 +158,12 @@ public boolean minValue(final BigInteger value, final long
min) {
*/
@Override
protected Object processParsedValue(final Object value, final Format
formatter) {
- return BigInteger.valueOf(((Number) value).longValue());
+ // A value that fits in a long is parsed as a Long; anything larger
comes back as a
+ // Double, whose longValue() saturates at Long.MAX_VALUE and loses the
magnitude.
Review Comment:
The commend does not make sense to me
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]