You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "Ray Chiang (JIRA)" <ji...@apache.org> on 2014/10/15 01:06:34 UTC

[jira] [Commented] (HADOOP-11199) Configuration should be able to set empty value for property

    [ https://issues.apache.org/jira/browse/HADOOP-11199?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14171685#comment-14171685 ] 

Ray Chiang commented on HADOOP-11199:
-------------------------------------

I believe it's intentional.  Otherwise, it would be impossible to document properties in the .xml file without accidentally setting a value.  Also, lots of code would have to be added to check for null/empty values (spaces have wreaked havoc with property values before).

I made a change in YARN-2284 (patch submitted, but not committed) that makes allowing empty values configurable (for unit testing).

> Configuration should be able to set empty value for property
> ------------------------------------------------------------
>
>                 Key: HADOOP-11199
>                 URL: https://issues.apache.org/jira/browse/HADOOP-11199
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: conf
>            Reporter: Wangda Tan
>
> Currently in hadoop.common.conf.Configuration, when you specify a XML like this:
> {code}
> <configuration>
>   <property>
>     <name>conf.name</name>
>     <value></value>
>   </property>
> </configuration>
> {code}
> When you trying to get the conf.name, the returned value is null instead of an empty string.
> Test code for this,
> {code}
> import java.io.ByteArrayInputStream;
> import org.apache.hadoop.conf.Configuration;
> public class HadoopConfigurationEmptyTest {
>   public static void main(String[] args) {
>     Configuration conf = new Configuration(false);
>     ByteArrayInputStream bais =
>         new ByteArrayInputStream(("<configuration><property>"
>             + "<name>conf.name</name>" + "<value></value>"
>             + "</property></configuration>").getBytes());
>     conf.addResource(bais);
>     System.out.println(conf.get("conf.name"));
>   }
> }
> {code}
> Does this intentionally or a behavior should be fixed?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)