Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-3005

Content does not correctly implement equals()

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Major
    • None
    • 4.2.3
    • core
    • Yes

    Description

      The Content class does not seem to correctly implement an equals() method. Running the following Groovy code via the Groovy Shell returns false, while I am pretty sure it should return true.

      ContentEqualsTest.groovy
      import info.magnolia.cms.util.*
      
      def repository = "website"
      def path = "/demo-project"
      def c1 = ContentUtil.getContent(repository, path)
      def c2 = ContentUtil.getContent(repository, path)
      return c1.equals(c2)
      

      Correctly implementing equals() and hashCode() is pretty important for working with objects like these. I ran into this bug while filling a Set with references to pages and noting that the same page was in the Set multiple times. I haven't checked if there are more objects that do not correctly implement equals() and/or hashCode(), but there may be more.

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              pbaerfuss Philipp Bärfuss
              breun Nils Breunese
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Checklists

                  Bug DoR
                  Task DoD