Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-1147

EnumUtils *BitVector issue with more than 32 values Enum

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 3.4
    • 3.5
    • lang.*
    • None

    Description

      In EnumUtils all BitVector related methods fail in handling Enums with more than 32 values.
      This is due to a implicit int -> long conversion in generating the Enum value long mask.

      Bad code : here 1 is an int value so the << operation is done into an int context and then, the result is converted to a long value

      long mask = 1 << 32;    // -> mask = 1 and not 4294967296 (0x100000000)
      

      Good code : here 1L is a long value so the << operation is done into an long context

      long mask = 1L << 32;    // -> mask = 4294967296 (0x100000000)
      

      See PR#97 : https://github.com/apache/commons-lang/pull/97

      Attachments

        Activity

          People

            Unassigned Unassigned
            rikles Loic Guibert
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: