Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-360

Why does appendIdentityToString return null?

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.4
    • None
    • None

    Description

      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.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            jogi Jörg Gottschling
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment