[ https://issues.apache.org/jira/browse/SOLR-1591?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12781298#action_12781298 ]
Yonik Seeley commented on SOLR-1591: ------------------------------------ Implementing a null check in one place can be better than implementing it in many. {code} String fooVal = map.get("foo"); if (fooVal != null) { writeAttr("foo", fooVal); } String barVal= map.get("bar"); if (barVal!= null) { writeAttr("bar", barVal); } ... {code} vs {code} writeAttr("foo", map.get("foo")); writeAttr("foo", map.get("bar")); ... {code} I've added the following javadoc to clarify: /** Writes the XML attribute name/val. A null val means that the attribute is missing */ > XMLWriter#writeAttr silently ignores null attribute values > ---------------------------------------------------------- > > Key: SOLR-1591 > URL: https://issues.apache.org/jira/browse/SOLR-1591 > Project: Solr > Issue Type: Bug > Affects Versions: 1.4 > Environment: My local MacBook pro laptop. > Reporter: Chris A. Mattmann > Priority: Minor > Fix For: 1.5 > > Attachments: SOLR-1591.Mattmann.112209.patch.txt > > > XMLWriter#writeAttr checks for val == null, and if so, does nothing. Instead > of doing nothing, it could leverage its method signature, and throw an > IOException declaring that the value provided is null. Patch, attached. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.