You are viewing a plain text version of this content. The canonical link for it is here.
Posted to proton@qpid.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2014/01/31 15:00:11 UTC

[jira] [Commented] (PROTON-501) [proton-j] UnsignedLong.valueOf(String) can permit values outside the allowed range

    [ https://issues.apache.org/jira/browse/PROTON-501?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13887767#comment-13887767 ] 

ASF subversion and git services commented on PROTON-501:
--------------------------------------------------------

Commit 1563134 from [~gemmellr] in branch 'proton/trunk'
[ https://svn.apache.org/r1563134 ]

PROTON-501, PROTON-502: fix range checking for UnsignedLong#valueOf(String). Add support for UnsignedLong#valueOf(BigInteger)

> [proton-j] UnsignedLong.valueOf(String) can permit values outside the allowed range
> -----------------------------------------------------------------------------------
>
>                 Key: PROTON-501
>                 URL: https://issues.apache.org/jira/browse/PROTON-501
>             Project: Qpid Proton
>          Issue Type: Bug
>          Components: proton-j
>    Affects Versions: 0.1, 0.2, 0.3, 0.4, 0.5, 0.6
>            Reporter: Robbie Gemmell
>            Assignee: Robbie Gemmell
>             Fix For: 0.7
>
>
> UnsignedLong#valueOf(String) attempts to ensure the provided value is in the range [0L- 2^64) but is likely to fail in doing.
> The method uses BigInteger#bitCount() as part of the process, which despite the name will not give the behaviour that might be expected:
> http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html#bitCount()
> "Returns the number of bits in the two's complement representation of this BigInteger that differ from its sign bit. This method is useful when implementing bit-vector style sets atop BigIntegers."
> The range check should probably be using:
> http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html#bitLength()



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)