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

Comparison of two proxied objects doesn't work even if the underlying objects are exactly the same

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Outdated
    • Icon: Major Major
    • None
    • 5.4
    • configuration, core
    • None

      This behavior was observed when analyzing PAGES-17.

      With the new registry API of 5.4, we proxy* all definitions that implement NamedDefinition. This proxy currently "decorates" the underlying definition objects to manage their ID and NAME properties.

      When two such proxied objects are compared, the calls to equals method are intercepted just like any other, and delegated to the underlying object. The arguments to the method are however not unwrapped, so the comparison never works.

      To illustrate:
      Given proxies p1 and p2, which respectively proxy o1 and o2 objects. o1==o2 and p1==p2 are both true. When calling p1.equals(p2), p1 intercepts the calls to equals and delegates it to o1, which essentially results in o1.equals(p2), which is obviously never true.

      I'm pretty sure I saw some equals (and possible hashcode) specific handling in ProxyToys somewhere, either it's optional or it's what's actually causing the issues. I'll dig it out !

      • for the sake of clarity/brevity, all "proxy" here actually refers to our usage of ProxyToys in the context of the configuration APIs. We also use ProxyToys in magnolia-i18n, so we'll need to verify the behavior there as well.

        Acceptance criteria

              Unassigned Unassigned
              pmundt Philip Mundt
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD