Return-Path: Delivered-To: apmail-commons-issues-archive@locus.apache.org Received: (qmail 79957 invoked from network); 5 Nov 2007 17:38:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Nov 2007 17:38:49 -0000 Received: (qmail 83251 invoked by uid 500); 5 Nov 2007 17:32:01 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 83177 invoked by uid 500); 5 Nov 2007 17:32:01 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 83167 invoked by uid 99); 5 Nov 2007 17:32:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Nov 2007 09:32:01 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Nov 2007 17:32:40 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 9C3B371420D for ; Mon, 5 Nov 2007 09:31:50 -0800 (PST) Message-ID: <11590900.1194283910628.JavaMail.jira@brutus> Date: Mon, 5 Nov 2007 09:31:50 -0800 (PST) From: "Paul Benedict (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (LANG-360) Why does appendIdentityToString return null? In-Reply-To: <12224872.1192969370591.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/LANG-360?page=3Dcom.atlassian.j= ira.plugin.system.issuetabpanels:comment-tabpanel#action_12540224 ]=20 Paul Benedict commented on LANG-360: ------------------------------------ Stephen says: "This method is meant to simulate the identity toString". Bas= ed on his words, I concur that passing a null object should throw an except= ion.=20 Thus I recommend: (1) return void to get rid of method chaining=20 (2) throw an exception is StringBuffer is null (3) throw an exception if Object is null #3 makes most sense. There is no identity to a null object. > Why does appendIdentityToString return null? > -------------------------------------------- > > Key: LANG-360 > URL: https://issues.apache.org/jira/browse/LANG-360 > Project: Commons Lang > Issue Type: Bug > Reporter: J=C3=B6rg Gottschling > Fix For: 2.4 > > Attachments: LANG-360.patch > > > ObjectUtils is designed to handle null imputs gracefully. But ObjectUtils= .appendIdentityToString does not. It returns null unnessecary if you pass n= ull als second parameter (the object to get the identity from). For example= appendIdentityToString(new StringBuffer(), null) will return null! Which i= s an uncommen behaviour. Think about code like this: > ObjectUtils.appendIdentityToString(buffer, param1) > .appendIdentityToString(buffer, param2) > .appendIdentityToString(buffer, param3); > This will cause an NPE if param1 or param2 ist null. There may be other c= ode where a NPE will not happen, but the code is used for debugging and the= re will be an unexpected or wrong output. > So you shoul return the StringBuffer which is passed in or a new one if n= ull. The harder question is what to do with the object. I think we should a= ppend "null" to the StringBuffer, because this is what I would expect and w= hat the passed reference is. --=20 This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.