-
Type:
Story
-
Status: Closed (View Workflow)
-
Priority:
Major
-
Resolution: Won't Do
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:
-
Environment:
Data that is put into ConsistentMap (and other primitives) 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 an object that contained information (a Map) that is order unaware and resulted in different serialized representations even though the values were semantically the same (Object::equals returns true). This can cause subtle bugs to creep in.
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
Data that is put into ConsistentMap (and other primitives) 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 an object that contained information (a Map) that is order unaware and resulted in different serialized representations even though the values were semantically the same (Object::equals returns true). This can cause subtle bugs to creep in. 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
-
Story Points:8
-
Epic Link:
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)