Author: yhemanth
Date: Tue Sep 1 15:24:56 2009
New Revision: 810097
URL: http://svn.apache.org/viewvc?rev=810097&view=rev
Log:
HADOOP-6227. Fix Configuration to allow final parameters to be set to null and
prevent them from being overridden. Contributed by Amareshwari Sriramadasu.
Modified:
hadoop/common/trunk/CHANGES.txt
hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java
hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfiguration.java
Modified: hadoop/common/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=810097&r1=810096&r2=810097&view=diff
==============================================================================
--- hadoop/common/trunk/CHANGES.txt (original)
+++ hadoop/common/trunk/CHANGES.txt Tue Sep 1 15:24:56 2009
@@ -951,6 +951,10 @@
HADOOP-6215. fix GenericOptionParser to deal with -D with '=' in the
value. (Amar Kamat via sharad)
+ HADOOP-6227. Fix Configuration to allow final parameters to be set to null
+ and prevent them from being overridden.
+ (Amareshwari Sriramadasu via yhemanth)
+
Release 0.20.1 - Unreleased
INCOMPATIBLE CHANGES
Modified: hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java?rev=810097&r1=810096&r2=810097&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java
(original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java Tue
Sep 1 15:24:56 2009
@@ -1286,17 +1286,20 @@
}
// 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/trunk/src/test/core/org/apache/hadoop/conf/TestConfiguration.java
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfiguration.java?rev=810097&r1=810096&r2=810097&view=diff
==============================================================================
---
hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfiguration.java
(original)
+++
hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfiguration.java
Tue Sep 1 15:24:56 2009
@@ -100,7 +100,28 @@
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);