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

SpringCache Put null value and get(key, clazz) IllegalStateException

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      SpringCacheTest,java
      public void testPutNullError() {
            //when//then
            cache.put("key", null);
      
            cache.get("key", String.class);
         }
      

      We get

      java.lang.IllegalStateException: Cached value is not of required type [java.lang.String]: org.infinispan.spring.provider.NullValue@76f7d241
      

      JavaDoc for this method states this method does not make difference between cached null and null value.

      Note: This variant of

      {@code get}

      does not allow for differentiating

      • between a cached {@code null}

        value and no cache entry found at all.

      • Use the standard {@link #get(Object)}

        variant for that purpose instead.

              karestig@redhat.com Katia Aresti
              karestig@redhat.com Katia Aresti
              Archiver:
              rhn-support-adongare Amol Dongare

                Created:
                Updated:
                Resolved:
                Archived: