[infinispan-issues] [JBoss JIRA] (ISPN-5803) Custom Key Results in ClassCastException in CacheLoader

Galder Zamarreño (JIRA) issues at jboss.org
Tue Oct 13 03:18:00 EDT 2015


    [ https://issues.jboss.org/browse/ISPN-5803?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13117607#comment-13117607 ] 

Galder Zamarreño commented on ISPN-5803:
----------------------------------------

I suspect this is a side effect of the default JCache configuration storeByValue setting, which is true. When storeByValue is enabled, entries are stored in binary format which is wrapped around MarshalledValue class. If you explicitly disable storeByValue it should work.

> Custom Key Results in ClassCastException in CacheLoader
> -------------------------------------------------------
>
>                 Key: ISPN-5803
>                 URL: https://issues.jboss.org/browse/ISPN-5803
>             Project: Infinispan
>          Issue Type: Bug
>          Components: JCache
>    Affects Versions: 8.0.1.Final
>            Reporter: Dan Siviter
>            Assignee: Galder Zamarreño
>             Fix For: 8.1.0.Alpha2, 8.1.0.Final
>
>
> If a a JCache is created using a read-through {{javax.cache.integration.CacheLoader}} using a custom Serializable key (in this case {{acme.MyCache$MyKey}}) a {{ClassCastException}} is thrown when trying to pass the key value of {{org.infinispan.marshall.core.MarshalledValue}} instead of {{MarshalledValue#get()}} into the {{CacheLoader}} instance.
> {code}
> java.lang.ClassCastException: org.infinispan.marshall.core.MarshalledValue cannot be cast to acme.MyCache$MyKey
> 	at acme.MyCache$2.load(MyCache.java:1) [my-app-1.0.0-SNAPSHOT.jar:]
> 	at org.infinispan.jcache.embedded.JCacheLoaderAdapter.loadKey(JCacheLoaderAdapter.java:65) [infinispan-jcache-8.0.1.Final.jar:8.0.1.Final]
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)



More information about the infinispan-issues mailing list