alhudz opened a new pull request, #1711: URL: https://github.com/apache/commons-lang/pull/1711
Repro: `new BitField(0x80000000)`, then `getRawValue(-1L)` / `clear(-1L)`. Expected: `getRawValue(-1L)` == `0x80000000` and `clear(-1L)` == `0xFFFFFFFF7FFFFFFF`, since only bit 31 belongs to the field. Actual: `getRawValue(-1L)` == `0xFFFFFFFF80000000` and `clear(-1L)` == `0x7FFFFFFF`, so bits 32-63 leak into the field. Cause: the `long mask` field and the long-typed methods arrived in 3.21.0, but `BitField(int)` still assigns the int mask straight into the `long` field, so any mask with bit 31 set is sign-extended across bits 32-63. The int-typed methods cast back to `int` and hide it, the long ones do not. Fix: build the field with `Integer.toUnsignedLong(mask)` so the int mask only occupies the low 32 bits. -- 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]
