Issue Details (XML | Word | Printable)

Key: LANG-360
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Jörg Gottschling
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons Lang

Why does appendIdentityToString return null?

Created: 21/Oct/07 12:22 PM   Updated: 12/Nov/07 10:54 PM
Return to search
Component/s: None
Affects Version/s: None
Fix Version/s: 2.4

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works LANG-360.patch 2007-11-12 08:23 PM Henri Yandell 4 kB
Text File Licensed for inclusion in ASF works LANG-360.patch 2007-11-03 08:01 AM Henri Yandell 5 kB

Resolution Date: 12/Nov/07 10:54 PM


 Description  « Hide
ObjectUtils is designed to handle null imputs gracefully. But ObjectUtils.appendIdentityToString does not. It returns null unnessecary if you pass null als second parameter (the object to get the identity from). For example appendIdentityToString(new StringBuffer(), null) will return null! Which is 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 code where a NPE will not happen, but the code is used for debugging and there will be an unexpected or wrong output.

So you shoul return the StringBuffer which is passed in or a new one if null. The harder question is what to do with the object. I think we should append "null" to the StringBuffer, because this is what I would expect and what the passed reference is.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
No work has yet been logged on this issue.