Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-9651

Binary objects comparison may fail when the same reference occurs more than once

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • binary
    • None
    • Docs Required

    Description

      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)

      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)));
      

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

      class Pojo { int i }
      class Key { int i, Pojo pojo }
      class Value { Pojo pojo, Key key }
      
      Pojo obj = new Pojo(42);
      Key key = new Key(42, 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");
      

      Attachments

        1. RepeatingFieldSqlTest.java
          5 kB
          Stanislav Lukyanov
        2. RepeatingFieldTest.java
          3 kB
          Stanislav Lukyanov

        Activity

          People

            Unassigned Unassigned
            slukyanov Stanislav Lukyanov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: