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

Javadoc Example for EqualsBuilder is questionable

    XMLWordPrintableJSON

Details

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

    Description

      The Javadoc example for the class EqualsBuilder ist questionable:

      public boolean equals(Object obj) {
      if (obj instanceof MyClass == false)

      { return false; }

      ...

      The implementation with instanceof lacks guarantees like equals-symmetry (see e.g. http://www.agiledeveloper.com/articles/equals062002.htm for a discussion of the issue)
      The example should be changed to use getClass(). Attention: the solution in the link above is incomplete as it doesn't check for null

      Attachments

        Activity

          People

            Unassigned Unassigned
            kutzi@gmx.de Christoph Kutzinski
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: