You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ha...@apache.org on 2012/01/06 06:42:24 UTC
svn commit: r1227964 - in
/hadoop/common/trunk/hadoop-common-project/hadoop-common: CHANGES.txt
src/main/java/org/apache/hadoop/conf/Configuration.java
src/test/java/org/apache/hadoop/conf/TestConfiguration.java
Author: harsh
Date: Fri Jan 6 05:42:24 2012
New Revision: 1227964
URL: http://svn.apache.org/viewvc?rev=1227964&view=rev
Log:
HADOOP-4515. Configuration#getBoolean must not be case sensitive. (Sho Shimauchi via harsh)
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1227964&r1=1227963&r2=1227964&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt Fri Jan 6 05:42:24 2012
@@ -86,6 +86,8 @@ Trunk (unreleased changes)
HADOOP-7957. Classes deriving GetGroupsBase should be able to override
proxy creation. (jitendra)
+ HADOOP-4515. Configuration#getBoolean must not be case sensitive. (Sho Shimauchi via harsh)
+
BUGS
HADOOP-7851. Configuration.getClasses() never returns the default value.
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java?rev=1227964&r1=1227963&r2=1227964&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java Fri Jan 6 05:42:24 2012
@@ -826,6 +826,12 @@ public class Configuration implements It
*/
public boolean getBoolean(String name, boolean defaultValue) {
String valueString = getTrimmed(name);
+ if (null == valueString || "".equals(valueString)) {
+ return defaultValue;
+ }
+
+ valueString = valueString.toLowerCase();
+
if ("true".equals(valueString))
return true;
else if ("false".equals(valueString))
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java?rev=1227964&r1=1227963&r2=1227964&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java Fri Jan 6 05:42:24 2012
@@ -451,6 +451,9 @@ public class TestConfiguration extends T
appendProperty("test.bool3", " true ");
appendProperty("test.bool4", " false ");
appendProperty("test.bool5", "foo");
+ appendProperty("test.bool6", "TRUE");
+ appendProperty("test.bool7", "FALSE");
+ appendProperty("test.bool8", "");
endConfig();
Path fileResource = new Path(CONFIG);
conf.addResource(fileResource);
@@ -459,6 +462,9 @@ public class TestConfiguration extends T
assertEquals(true, conf.getBoolean("test.bool3", false));
assertEquals(false, conf.getBoolean("test.bool4", true));
assertEquals(true, conf.getBoolean("test.bool5", true));
+ assertEquals(true, conf.getBoolean("test.bool6", false));
+ assertEquals(false, conf.getBoolean("test.bool7", true));
+ assertEquals(false, conf.getBoolean("test.bool8", false));
}
public void testFloatValues() throws IOException {