vasiliy-mikhailov opened a new pull request, #28557:
URL: https://github.com/apache/flink/pull/28557

   ## What is the purpose of the change
   
   `MathUtils.isPowerOf2(long)` returns `true` for `0` and for `Long.MIN_VALUE`,
   neither of which is a power of two. `0 & (0 - 1) == 0` and
   `Long.MIN_VALUE & (Long.MIN_VALUE - 1) == 0`, so the existing bit trick alone
   misclassifies non-positive inputs. This fixes
   [FLINK-33725](https://issues.apache.org/jira/browse/FLINK-33725).
   
   ## Brief change log
   
   - Guard `isPowerOf2` with `value > 0` so non-positive values return `false`.
   - Extend `MathUtilTest#testPowerOfTwo` with the `0`, `-1` and 
`Long.MIN_VALUE`
     cases.
   
   ## Verifying this change
   
   This change is covered by the additional assertions in
   `MathUtilTest#testPowerOfTwo`, which fail before the fix and pass after.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies: no
     - Public API / @Public(Evolving): no
     - Serializers / checkpointing / state: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? no
   


-- 
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]

Reply via email to