Author: stack
Date: Tue Feb  7 23:49:37 2012
New Revision: 1241704

URL: http://svn.apache.org/viewvc?rev=1241704&view=rev
Log:
HBASE-5348 Constraint configuration loaded with bloat

Modified:
    
hbase/trunk/src/main/java/org/apache/hadoop/hbase/constraint/Constraints.java
    
hbase/trunk/src/test/java/org/apache/hadoop/hbase/constraint/CheckConfigurationConstraint.java
    
hbase/trunk/src/test/java/org/apache/hadoop/hbase/constraint/TestConstraints.java

Modified: 
hbase/trunk/src/main/java/org/apache/hadoop/hbase/constraint/Constraints.java
URL: 
http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/constraint/Constraints.java?rev=1241704&r1=1241703&r2=1241704&view=diff
==============================================================================
--- 
hbase/trunk/src/main/java/org/apache/hadoop/hbase/constraint/Constraints.java 
(original)
+++ 
hbase/trunk/src/main/java/org/apache/hadoop/hbase/constraint/Constraints.java 
Tue Feb  7 23:49:37 2012
@@ -365,7 +365,7 @@ public final class Constraints {
   private static Configuration readConfiguration(byte[] bytes)
       throws IOException {
     ByteArrayInputStream is = new ByteArrayInputStream(bytes);
-    Configuration conf = new Configuration();
+    Configuration conf = new Configuration(false);
     conf.addResource(is);
     return conf;
   }

Modified: 
hbase/trunk/src/test/java/org/apache/hadoop/hbase/constraint/CheckConfigurationConstraint.java
URL: 
http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/constraint/CheckConfigurationConstraint.java?rev=1241704&r1=1241703&r2=1241704&view=diff
==============================================================================
--- 
hbase/trunk/src/test/java/org/apache/hadoop/hbase/constraint/CheckConfigurationConstraint.java
 (original)
+++ 
hbase/trunk/src/test/java/org/apache/hadoop/hbase/constraint/CheckConfigurationConstraint.java
 Tue Feb  7 23:49:37 2012
@@ -29,7 +29,7 @@ public class CheckConfigurationConstrain
   private static String value = "testValue";
 
   public static Configuration getConfiguration() {
-    Configuration conf = new Configuration();
+    Configuration conf = new Configuration(false);
     conf.set(key, value);
     return conf;
   }
@@ -47,6 +47,13 @@ public class CheckConfigurationConstrain
       if (val == null || !val.equals(value))
         throw new IllegalArgumentException(
             "Configuration was not passed correctly");
+      // and then check to make sure we got a fresh config by checking for a
+      // hadoop-based config value, and if we don't find it, its fine
+      if (conf.getRaw("fs.file.impl") != null)
+        throw new IllegalArgumentException(
+            "Configuration was created using 'new Configuration()', should be "
+                + "done via 'new Configuration(false) to exclude defaut hadoop 
"
+                + "configurations values.");
     }
   }
 

Modified: 
hbase/trunk/src/test/java/org/apache/hadoop/hbase/constraint/TestConstraints.java
URL: 
http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/constraint/TestConstraints.java?rev=1241704&r1=1241703&r2=1241704&view=diff
==============================================================================
--- 
hbase/trunk/src/test/java/org/apache/hadoop/hbase/constraint/TestConstraints.java
 (original)
+++ 
hbase/trunk/src/test/java/org/apache/hadoop/hbase/constraint/TestConstraints.java
 Tue Feb  7 23:49:37 2012
@@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.constrai
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.util.List;
 
@@ -82,11 +83,11 @@ public class TestConstraints {
 
     // check to make sure that we overwrite configurations
     Constraints.add(desc, new Pair<Class<? extends Constraint>, Configuration>(
-        CheckConfigurationConstraint.class, new Configuration()));
+        CheckConfigurationConstraint.class, new Configuration(false)));
 
     try {
       Constraints.getConstraints(desc, this.getClass().getClassLoader());
-      assertTrue("No exception thrown  - configuration not overwritten", 
false);
+      fail("No exception thrown  - configuration not overwritten");
     } catch (IllegalArgumentException e) {
       // expect to have the exception, so don't do anything
     }


Reply via email to