protected static int getNextBitMask(int mask, final int maxValue) {
    mask <<= 1;
    if (mask > maxValue) {
      Assert.fail("exhausted bit flags with all available bits: 0x" + Integer.toHexString(mask)
          + ", max: 0x" + Integer.toHexString(maxValue));
    }
    return mask;
  }
Get the next bit mask position while checking that the value should not exceed given maximum
value.
geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionMessage.java