Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 9
    • Affects Version/s: 9
    • Component/s: core-libs
    • None

      The implementations of VarHandle.getAndAdd/addAndGet for the byte[]/ByteBuffer views are incorrect if endian conversion is performed. The atomic addition is performed on the encoded augend.

      It just so happened that the associated tests use values that do not result in overflow over the byte ranges, hence a bad result was not observed.
       
      If the native endianess does not match that on the VarHandle then the atomic add should be performed in a CAS loop.

            Assignee:
            Paul Sandoz
            Reporter:
            Paul Sandoz
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: