HBASE-15283 Revert to IOException in TimeRange constructor to maintain API compat in 1.x line

[branch-1 and branch-1.2 only] HBASE-14355 changed the type of exception thrown if an invalid TimeRange is specified.  This reverts to 1.1.x semantics.
This commit is contained in:
Jonathan M Hsieh 2016-02-17 11:20:23 -08:00
parent 455e09c325
commit 2e1a3ef644
2 changed files with 21 additions and 5 deletions

View File

@ -17,6 +17,7 @@
*/
package org.apache.hadoop.hbase.client;
import java.io.IOException;
import java.util.Map;
import com.google.common.collect.Maps;
@ -192,8 +193,12 @@ public abstract class Query extends OperationWithAttributes {
*/
public Query setColumnFamilyTimeRange(byte[] cf, long minStamp, long maxStamp) {
colFamTimeRangeMap.put(cf, new TimeRange(minStamp, maxStamp));
return this;
try {
colFamTimeRangeMap.put(cf, new TimeRange(minStamp, maxStamp));
return this;
} catch (IOException ioe) {
throw new IllegalArgumentException(ioe);
}
}
/**

View File

@ -43,7 +43,9 @@ public class TimeRange {
/**
* Default constructor.
* Represents interval [0, Long.MAX_VALUE) (allTime)
* @deprecated This is made @InterfaceAudience.Private in the 2.0 line and above
*/
@Deprecated
public TimeRange() {
allTime = true;
}
@ -51,7 +53,9 @@ public class TimeRange {
/**
* Represents interval [minStamp, Long.MAX_VALUE)
* @param minStamp the minimum timestamp value, inclusive
* @deprecated This is made @InterfaceAudience.Private in the 2.0 line and above
*/
@Deprecated
public TimeRange(long minStamp) {
this.minStamp = minStamp;
}
@ -59,7 +63,9 @@ public class TimeRange {
/**
* Represents interval [minStamp, Long.MAX_VALUE)
* @param minStamp the minimum timestamp value, inclusive
* @deprecated This is removed in the 2.0 line and above
*/
@Deprecated
public TimeRange(byte [] minStamp) {
this.minStamp = Bytes.toLong(minStamp);
}
@ -68,15 +74,18 @@ public class TimeRange {
* Represents interval [minStamp, maxStamp)
* @param minStamp the minimum timestamp, inclusive
* @param maxStamp the maximum timestamp, exclusive
* @throws IllegalArgumentException
* @throws IllegalArgumentException if either <0,
* @throws IOException if max smaller than min.
* @deprecated This is made @InterfaceAudience.Private in the 2.0 line and above
*/
public TimeRange(long minStamp, long maxStamp) {
@Deprecated
public TimeRange(long minStamp, long maxStamp) throws IOException {
if (minStamp < 0 || maxStamp < 0) {
throw new IllegalArgumentException("Timestamp cannot be negative. minStamp:" + minStamp
+ ", maxStamp:" + maxStamp);
}
if(maxStamp < minStamp) {
throw new IllegalArgumentException("maxStamp is smaller than minStamp");
throw new IOException("maxStamp is smaller than minStamp");
}
this.minStamp = minStamp;
this.maxStamp = maxStamp;
@ -87,7 +96,9 @@ public class TimeRange {
* @param minStamp the minimum timestamp, inclusive
* @param maxStamp the maximum timestamp, exclusive
* @throws IOException
* @deprecated This is removed in the 2.0 line and above
*/
@Deprecated
public TimeRange(byte [] minStamp, byte [] maxStamp)
throws IOException {
this(Bytes.toLong(minStamp), Bytes.toLong(maxStamp));