|
[
Permlink
| « Hide
]
Knut Anders Hatlen added a comment - 13/Jul/07 09:37 AM
The attached patch fixes the decoding by forcing promotion of the operands to long. The regression tests ran cleanly.
Is it possible to write a new regression test, with some Long values which
require 6 and/or 8 bytes to encode, which demonstrates the bug and the fix? I don't think it's possible to test the fix with a JDBC test, at least, since Derby doesn't support data types with length >= 2^31, but it might be possible to force 6 and 8 byte values in derbynet/testProtocol.java. I'll see if I can come up with something.
Adding a test which used 8 bytes for the length wasn't that difficult, but since there is no way of sending data that needs the high four bytes of the length field, the test passes regardless of the fix. So I guess the best way to demonstrate the bug and the fix is by running this program:
public class ll { public static void main(String[] args) { long l1 = ((byte) 1 & 0xFF) << 56; long l2 = ((byte) 1 & 0xFFL) << 56; System.out.println("l1 = " + l1); System.out.println("l2 = " + l2); } } Which prints: l1 = 16777216 l2 = 72057594037927936 Attaching a test which uses 8 bytes for the length. The test passes both with and without the fix. I'm only attaching it in case someone wants to experiment with it to find ways to expose the bug.
Committed revision 557513.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||