Jens Borgland created IGNITE-23119:
--------------------------------------

             Summary: Unstable serialization of sets may cause comparisons to 
fail
                 Key: IGNITE-23119
                 URL: https://issues.apache.org/jira/browse/IGNITE-23119
             Project: Ignite
          Issue Type: Bug
          Components: binary
    Affects Versions: 2.16
            Reporter: Jens Borgland
         Attachments: SetSerializationBugRepro.java

If an object containing a {{HashSet}} is added as value to a cache and then 
loaded again it may (depending on the contents of the set) be impossible to 
pass it as {{oldVal}} to {{replace(K V V)}} and similar methods since the 
comparison between the passed value and the stored value will fail (despite the 
objects being logically equal).

*Example*
The code below, where {{ValueClass}} is a simple DTO that stores the given set 
as its only member variable, will result in {{false}} being printed.
{code:java}
    final Ignite ignite = Ignition.start(new IgniteConfiguration());
    final IgniteCache<String, ValueClass> cache = 
ignite.getOrCreateCache("cache");

    final HashSet<String> set = new HashSet<>();
    set.add("http://dashboard:8083/oauth";);
    set.add("http://dashboard:8083/auth";);

    // Put a value in the cache
    cache.put(KEY, new ValueClass(set));

    ValueClass oldVal = cache.get(KEY);

    boolean replaced = cache.replace(KEY, oldVal, new 
ValueClass(Collections.emptyList()));
    System.out.println(replaced);

    ignite.close();
{code}
I'm also attaching a JUnit test case demonstrating the issue.

*Expected*
To be able to pass the loaded value as {{oldVal}} to methods like {{replace(K V 
V)}} and {{remove(K V)}} even when using unordered sets. Should perhaps the 
items of unordered sets be sorted before being serialized?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to