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

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

    XMLWordPrintable

Details

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              karestig@redhat.com Katia Aresti
              karestig@redhat.com Katia Aresti
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: