Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

sequence range get/set fails when num is bigger than Interger.MAX_VAL

  • Loading branch information...
commit a4718525726f213f8fc27b692f554c5c150c1fb4 1 parent 434760c
Youngjae Chang authored
Showing with 5 additions and 3 deletions.
  1. +5 −3 src/org/jgroups/util/SeqnoRange.java
View
8 src/org/jgroups/util/SeqnoRange.java
@@ -18,6 +18,8 @@ public SeqnoRange(long low, long high) {
this.high=high;
if(low > high)
throw new IllegalArgumentException("low (" + low + ") must be <= high (" + high + ")");
+ if((high - low) >= Integer.MAX_VALUE)
+ throw new IllegalArgumentException("range (" + low + "-" + high + ") size is too big ");
int size=(int)((high - low) + 1);
bits=new FixedSizeBitSet(size); // starts out with all bits set to 0 (false)
}
@@ -32,11 +34,11 @@ public boolean contains(long num) {
}
public boolean get(long num) {
- return bits.get(getIndex((int)num));
+ return bits.get(getIndex(num));
}
public void set(long num) {
- bits.set(getIndex((int)num));
+ bits.set(getIndex(num));
}
public void set(long ... nums) {
@@ -80,7 +82,7 @@ public String print() {
return low + "-" + high + ", set=" + printBits(true) + ", cleared=" + printBits(false);
}
- protected int getIndex(int num) {
+ protected int getIndex(long num) {
if(num < low || num > high)
throw new IllegalArgumentException(num + " is outside the range " + toString());
return (int)(num - low);
Please sign in to comment.
Something went wrong with that request. Please try again.