You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ignite.apache.org by "Stanislav Lukyanov (JIRA)" <ji...@apache.org> on 2018/09/19 18:14:00 UTC

[jira] [Created] (IGNITE-9651) Binary objects comparison may fail when the same reference occurs more than once

Stanislav Lukyanov created IGNITE-9651:
------------------------------------------

             Summary: Binary objects comparison may fail when the same reference occurs more than once
                 Key: IGNITE-9651
                 URL: https://issues.apache.org/jira/browse/IGNITE-9651
             Project: Ignite
          Issue Type: Bug
          Components: binary
            Reporter: Stanislav Lukyanov
         Attachments: RepeatingFieldSqlTest.java, RepeatingFieldTest.java

If a composite object contains multiple occurrences of the same POJO that POJO will be properly serialized only the first time, and all other references will refer to that first object. Because of that the same object may have different views in binary format when serialized on its own and when serialized as a part of another object.

Having multiple binary views of the same object leads to several issues with binary objects comparison. Examples in pseudocode are below, JUnit tests are attached

========================
Example 1 (RepeatingFieldTest.java)
{code}
class Key { int i, Pojo pojo1, Pojo pojo2 }
class Pojo { int i }

cache.put(new Key(42, new Pojo(42), new Pojo(42)), 42);

// new Pojo is created for both fields - works
assertEquals(INT, cache.get(new Key(42, new Pojo(42), new Pojo(42))));

// same Pojo is used for both fields - fails
// this is because the second field is serialized as a reference to the first one, and binary representation differs
Pojo obj = new Pojo(42);
assertEquals(42, cache.get(new Key(42, obj, obj)));
{code}

========================
Example 2 (RepeatingFieldSqlTest.java)

{code}
class Pojo { int i }
class Key { int i, Pojo pojo }
class Value { Pojo pojo, Key key }

Pojo obj = new Pojo(INT);
Key key = new Key(INT, obj);
Value val = new Value(key, obj);
cache.put(key, val);

// supposed to return 1 row, but returns 0
SqlFieldsQuery qry = new SqlFieldsQuery("select * from Value where _key = key");

{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)