[infinispan-issues] [JBoss JIRA] (ISPN-7783) ClassCastException in case of configured read-through cache with some cache loader

Roman Chigvintsev (JIRA) issues at jboss.org
Wed May 3 10:53:00 EDT 2017


     [ https://issues.jboss.org/browse/ISPN-7783?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Roman Chigvintsev updated ISPN-7783:
------------------------------------
    Steps to Reproduce: 
*Configure cache in invalidation mode in XML:*

{code: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>
{code}

*Provide cache loader configuration through JCache API:*

{code:java}
new MutableConfiguration<String, User>()
    .setReadThrough(true).setStoreByValue(true)
    .setCacheLoaderFactory(FactoryBuilder.factoryOf(UserCacheLoader.class));
{code}

Cache loader can be trivial:

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

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


  was:
# Configure cache in invalidation mode in XML:

{code: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>
{code}

# Provide cache loader configuration through JCache API:

{code:java}
new MutableConfiguration<String, User>()
    .setReadThrough(true).setStoreByValue(true)
    .setCacheLoaderFactory(FactoryBuilder.factoryOf(UserCacheLoader.class));
{code}

Cache loader can be trivial:

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

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




> ClassCastException in case of configured read-through cache with some cache loader
> ----------------------------------------------------------------------------------
>
>                 Key: ISPN-7783
>                 URL: https://issues.jboss.org/browse/ISPN-7783
>             Project: Infinispan
>          Issue Type: Bug
>          Components: JCache
>    Affects Versions: 8.2.1.Final, 9.0.0.Final
>            Reporter: Roman Chigvintsev
>
> 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.



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)


More information about the infinispan-issues mailing list