Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-15317

Unable to query cached records with custom key objects that have null fields

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor Minor
    • 14.0.22.Final, 15.0.0.Final
    • None
    • None
    • None

      Hey team, I am running into an issue with having null fields in custom key objects in my RemoteCache. We are currently using a replicated cache and is configured with a query-jdbc-store that connects to a Postgres database table. The key that we use to store records in the cache is a custom object that typically has 5 fields, however, one of them will need to sometimes be null (which we are still considering as a unique value), ex: String origin = null;. The problem that I am having is: when a record is added to the Postgres table that has that one field set to null, which then gets pull into the cache, we want to be able to query the record out of the cache using the get() method from another application, but using a key that has that field set to null will return a null for the result of the get() call. However, using an empty string “” in the key for that field will find the record in the cache but for some reason Infinispan will create a new copy of that record with a new key that has the origin field set to an empty string, ex “origin” : “”. So now there is two records exactly the same except one has no origin field, and the other has the origin field set to an empty string.

      Now, if I don’t use the Postgres database and only store the record in the cache (still using a null value for the origin field in the key), then get() calls using a null value for the origin field will retrieve the record from the cache just fine. This seems like a strange issue and I am wondering if it has something to do with how records are pulled out of the database and put into the cache. 

       
      We are also using the default ProtoStreamMarshaller

      I created a test project so that I can show the logs here. Attached are the logs of when I am able to get a record with a non-null origin field using a key with a non-null origin in the get() call, and the logs of when I cannot get a record with a null origin using null for the origin in the key used in the get(). 

            remerson@redhat.com Ryan Emerson
            eli.lawrence Eli Lawrence (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: