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

ClassCastException in case of configured read-through cache with some cache loader

    Details

    • Steps to Reproduce:
      Hide

      1). Configure cache in invalidation mode in XML:

      <?xml version="1.0" encoding="UTF-8"?>
      <infinispan xmlns="urn:infinispan:config:8.2">
          <cache-container default-cache="default">
              <transport cluster="jcache-cluster"/>
              <invalidation-cache-configuration name="user" mode="SYNC" statistics="true"/>
          </cache-container>
      </infinispan>
      

      2). Provide cache loader configuration through JCache API:

      new MutableConfiguration<String, User>()
          .setReadThrough(true).setStoreByValue(true)
          .setCacheLoaderFactory(FactoryBuilder.factoryOf(UserCacheLoader.class));
      

      Cache loader can be trivial:

      public class UserCacheLoader implements CacheLoader<String, User> {
          @Override
          public User load(String username) {
              return new User(username);
          }
      }
      

      3). Load serveral users into the cache.
      4). Call `javax.cache.Cache.removeAll()` method on the cache instance.

      Show
      1). Configure cache in invalidation mode in XML: <? xml version = "1.0" encoding = "UTF-8" ?> < infinispan xmlns = "urn:infinispan:config:8.2" > < cache -container default-cache = "default" > < transport cluster = "jcache-cluster" /> < invalidation -cache-configuration name = "user" mode = "SYNC" statistics = "true" /> </ cache -container> </ infinispan > 2). Provide cache loader configuration through JCache API: new MutableConfiguration<String, User>() .setReadThrough( true ).setStoreByValue( true ) .setCacheLoaderFactory(FactoryBuilder.factoryOf(UserCacheLoader. class )); Cache loader can be trivial: public class UserCacheLoader implements CacheLoader<String, User> { @Override public User load(String username) { return new User(username); } } 3). Load serveral users into the cache. 4). Call `javax.cache.Cache.removeAll()` method on the cache instance.

      Description

      When cache is configured through JCache API as a read-through cache with some cache loader Infinispan puts cache values provided by that loader in place of keys. It causes `java.lang.ClassCastException` after calling of `javax.cache.Cache.removeAll` method. Iteration on cache also turns out to be broken.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                positive_coder Roman Chigvintsev
                Reporter:
                positive_coder Roman Chigvintsev
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: