Uploaded image for project: 'Errai'
  1. Errai
  2. ERRAI-947

TransmissionBuffer write sequence (seq) becomes negative thus leading to AIOOBE all the time

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Critical
    • Resolution: Done
    • Affects Version/s: 3.0.1.Final, 2.4.5.Final, 3.1.2.Final, 3.2.3.Final
    • Fix Version/s: 4.0.0.Beta4
    • Component/s: ErraiBus
    • Labels:
      None
    • Steps to Reproduce:
      Hide

      start with a big writeSequenceNumber multiple of segments, near to Integer.MAX_VALUE

      Show
      start with a big writeSequenceNumber multiple of segments, near to Integer.MAX_VALUE

      Description

      TransmissionBuffer write method calculates the write sequence as follows:

      final int seq = (int) writeHead % segments;

      This will lead to a negative seq when writeHead which is a long will get bigger than Integer.MAX_VALUE and will be cast to int, because the cast will take precedence over the % operation. From there on, all the writes to the buffer will fail with an AIOOBE, so no messages at all.

      the fix is fairly simple, just add the needed paranthesis:
      final int seq = (int) (writeHead % segments);

      Of course that it needs to be fixed in all places where this operation appears!

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                mbarkley Max Barkley
                Reporter:
                ggaborg Gab And
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: