Uploaded image for project: 'Spring Roo'
  1. Spring Roo
  2. ROO-1426

Fix dodgy proxy equality semantics

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Critical
    • Resolution: Complete
    • Affects Version/s: None
    • Fix Version/s: 1.1.0.RC1
    • Component/s: GWT
    • Labels:
      None

      Description

      In M4, two proxies are equal if their stableId values are equal. This is convenient, but a little too equal and will lead to confusion and subtle bugs — proxies that have been made editable against different requests will be equal, and yet can have different property values:

      aProxy.equals(bProxy)
      does not imply that
      aProxy.getSomeProperty().equals(bProxy.getSomeProperty())

      Instead, they probably should be equal if they have the same stable id, and are bound to the same request, or are both bound to no request.

      The tricky bit is making sure that proxies with this semantic don't become basically unusable to use with collections. e.g.:

      So I have a Foo with a Set<Bar>, and it contains 1 Bar with ID 999. My test tries to remove this relation, so I do:

      Fetch the FooProxy
      Fetch BarProxy for ID 999
      FooProxy.getSet().remove(barProxy); => will always fail silently

      The only way to do the remove is to use an Iterator, implement your own check using stableId(), and call iterator.remove() when you find the match by stableId.

        Attachments

          Activity

            People

            Assignee:
            bobv Robert Vawter
            Reporter:
            rjrjr@google.com Ray Ryan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: