Uploaded image for project: 'XNIO'
  1. XNIO
  2. XNIO-149

NioTcpServer ignores higher precedence of bitwise shift operations over | and &

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 3.1.0.Beta2
    • None
    • None
    • None
    • Workaround Exists

      At some points of NioTcpServer, the bitwise shift operations (<< and >>) are being performed against partial numbers, as the higher precedence of <</>> over other bitwise operations (XOR, OR, and AND) is being ignored. For example:
      a & b >> c
      Should be instead:
      (a & b) >> c
      Or else the piece of code above would read as
      a & (b >> c)

      An example of where this occurs is the getHighWater(long) method:
      private static int getHighWater(final long value)

      { return (int) (value & CONN_HIGH_MASK >> CONN_HIGH_BIT); }

      The correct is:
      private static int getHighWater(final long value)

      { return (int) ((value & CONN_HIGH_MASK) >> CONN_HIGH_BIT); }

      All the points of NioTcpServer that use the shift operators should be reviewed, and fixed whenever needed.

            flaviarnn Flavia Rainone
            flaviarnn Flavia Rainone
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: