hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject svn commit: r1076993 - in /hadoop/common/branches/branch-0.20-security-patches/src: core/org/apache/hadoop/conf/Configuration.java test/org/apache/hadoop/conf/TestConfiguration.java
Date Fri, 04 Mar 2011 03:28:46 GMT
Author: omalley
Date: Fri Mar  4 03:28:46 2011
New Revision: 1076993

URL: http://svn.apache.org/viewvc?rev=1076993&view=rev
Log:
commit 6d30f4cd994a53b5d11f02c1915f0a0cdc349170
Author: Yahoo\! <ltucker@yahoo-inc.com>
Date:   Thu Sep 3 11:25:54 2009 -0700

    HADOOP:6227 from http://issues.apache.org/jira/secure/attachment/12418242/patch-6227-ydist.txt

Modified:
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/conf/Configuration.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/conf/TestConfiguration.java

Modified: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/conf/Configuration.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/conf/Configuration.java?rev=1076993&r1=1076992&r2=1076993&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/conf/Configuration.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/conf/Configuration.java
Fri Mar  4 03:28:46 2011
@@ -1183,17 +1183,20 @@ public class Configuration implements It
         }
         
         // Ignore this parameter if it has already been marked as 'final'
-        if (attr != null && value != null) {
-          if (!finalParameters.contains(attr)) {
-            properties.setProperty(attr, value);
-            if (storeResource) {
-              updatingResource.put(attr, name.toString());
-            }
-            if (finalParameter)
-              finalParameters.add(attr);
-          } else {
-            LOG.warn(name+":a attempt to override final parameter: "+attr
+        if (attr != null) {
+          if (value != null) {
+            if (!finalParameters.contains(attr)) {
+              properties.setProperty(attr, value);
+              if (storeResource) {
+                updatingResource.put(attr, name.toString());
+              }
+            } else {
+              LOG.warn(name+":a attempt to override final parameter: "+attr
                      +";  Ignoring.");
+            }
+          }
+          if (finalParameter) {
+            finalParameters.add(attr);
           }
         }
       }

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/conf/TestConfiguration.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/conf/TestConfiguration.java?rev=1076993&r1=1076992&r2=1076993&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/conf/TestConfiguration.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/conf/TestConfiguration.java
Fri Mar  4 03:28:46 2011
@@ -104,7 +104,28 @@ public class TestConfiguration extends T
     assertTrue(conf.getInt("intvar", -1) == 42);
     assertTrue(conf.getInt("my.int", -1) == 42);
   }
-    
+
+  public void testFinalParam() throws IOException {
+    out=new BufferedWriter(new FileWriter(CONFIG));
+    startConfig();
+    declareProperty("my.var", "", "", true);
+    endConfig();
+    Path fileResource = new Path(CONFIG);
+    Configuration conf1 = new Configuration();
+    conf1.addResource(fileResource);
+    assertNull("my var is not null", conf1.get("my.var"));
+	
+    out=new BufferedWriter(new FileWriter(CONFIG2));
+    startConfig();
+    declareProperty("my.var", "myval", "myval", false);
+    endConfig();
+    fileResource = new Path(CONFIG2);
+
+    Configuration conf2 = new Configuration(conf1);
+    conf2.addResource(fileResource);
+    assertNull("my var is not final", conf2.get("my.var"));
+  }
+
   public static void assertEq(Object a, Object b) {
     System.out.println("assertEq: " + a + ", " + b);
     assertEquals(a, b);



Mime
View raw message