You are viewing a plain text version of this content. The canonical link for it is here.
Posted to proton@qpid.apache.org by "Robbie Gemmell (JIRA)" <ji...@apache.org> on 2014/01/31 13:00:12 UTC
[jira] [Created] (PROTON-501) [proton-j]
UnsignedLong.valueOf(String) can permit values outside the allowed range
Robbie Gemmell created PROTON-501:
-------------------------------------
Summary: [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.6, 0.5, 0.4, 0.3, 0.2, 0.1
Reporter: 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()
{quote}
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.
{quote}
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)