Uploaded image for project: 'ONOS'
  1. ONOS
  2. ONOS-3561

ConsistentMap is not compatible with Object::equals

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Won't Do
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Environment:
    • Story Points:
      8
    • Epic Link:

      Description

      Data that is put into a ConsistentMap (and for that matter any other typed primitive) gets serialized into byte[] first. That means equality of keys/values is determined by comparing their serialized byte[] representations. This is a subtle limitation that is easy for an app developer to miss. We have already seen a few instances where someone was using a type that did not always produce the same bytes when serialized (ex: order unaware Map) and therefore even though the values were semantically the same (a.equals(b) returns true), the underlying primitive treated them as two distinct values.

      We need a way to improve this situation. Options include fixing:

      • ConsistentMap to rely on Object::equals (hard)
      • Preempt errors by warning when equality as determined by Object::equals can be different from equality of serialized byte[] representations (also hard)
      • Document this limitation more thoroughly
      • Another alternate is to ensure the underlying state machine (in copycat) itself is type aware. This is can accomplished by passing the appropriate serializer to copycat. However, the problem with this is that types (that are serialized) can come from third party apps, meaning the types are register at primitive creation time. Whereas the underlying state machine serializer needs to be registered up front (when the system is initialized). Therefore this solution can only works when the type is a standard type (btw, ONOS API types are considered standard)

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            sangyun-han sangyun han
            Reporter:
            madan Madan Jampani
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: