From 93e475e5ba5d5893a5d2fcb0ad87d03d51afbd2f Mon Sep 17 00:00:00 2001 From: tedyu Date: Fri, 29 May 2015 07:34:00 -0700 Subject: [PATCH] HBASE-13776 Setting illegal versions for HColumnDescriptor does not throw IllegalArgumentException (Yuhao Bi) --- .../java/org/apache/hadoop/hbase/master/HMaster.java | 9 +++++++++ .../apache/hadoop/hbase/client/TestFromClientSide.java | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java index 7383615ef2b..aaf288a1856 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -1498,6 +1498,15 @@ public class HMaster extends HRegionServer implements MasterServices, Server { } // max versions already being checked + // HBASE-13776 Setting illegal versions for HColumnDescriptor + // does not throw IllegalArgumentException + // check minVersions <= maxVerions + if (hcd.getMinVersions() > hcd.getMaxVersions()) { + String message = "Min versions for column family " + hcd.getNameAsString() + + " must be less than the Max versions."; + warnOrThrowExceptionForFailure(logWarn, CONF_KEY, message, null); + } + // check replication scope if (hcd.getScope() < 0) { String message = "Replication scope for column family " diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java index 1fea802574c..02eca778bdd 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java @@ -5566,6 +5566,14 @@ public class TestFromClientSide { } checkTableIsLegal(htd); + // HBASE-13776 Setting illegal versions for HColumnDescriptor + // does not throw IllegalArgumentException + // finally, minVersions must be less than or equal to maxVersions + hcd.setMaxVersions(4); + hcd.setMinVersions(5); + checkTableIsIllegal(htd); + hcd.setMinVersions(3); + hcd.setScope(-1); checkTableIsIllegal(htd); hcd.setScope(0);