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

Distributed iterator throws ClassCastException when loader contains values that pass filter

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Done
    • 7.0.0.Alpha5
    • 7.0.0.Beta1
    • Core
    • None

    Description

      This code will iterate over all of the entries in a cache to get the total size:

            public int getTotalSize() {
               log.info(getClass().getName() + ".getTotalSize() for cache " + cache.getName());
               int totalSize = 0;
               EntryIterable entryIterator = null;
               try {
                  entryIterator = cache.filterEntries(new AllEntriesFilter());
                  CloseableIterable ci = entryIterator.converter(new AllEntriesConverter());
                  Iterator iter = ci.iterator();
                  while (iter.hasNext()) {
                     iter.next();
                     totalSize++;
                  }
                  return totalSize;
               } finally {
                  if (entryIterator != null) {
                     try {
                        entryIterator.close();
                     } catch (Exception e) {
                        log.error("Failed to close EntryIterable", e);
                     }
                  }
               }
            }
      

      I wanted to verify that this code would also work when I was using passivation and a cachestore. The repl-udp-no-tx-leveldb-jni.xml file defines the configuration that I am using. I run a test that puts random data into the cache then checks the size of the cache, but I am getting a bunch of ClassCastException exceptions during the iteration:

      java.lang.ClassCastException: java.lang.String cannot be cast to org.infinispan.container.entries.InternalCacheEntry
              at org.infinispan.iteration.impl.LocalEntryRetriever$MapAction.apply(LocalEntryRetriever.java:251)
              at org.infinispan.iteration.impl.LocalEntryRetriever$KeyValueActionForCacheLoaderTask.processEntry(LocalEntryRetriever.java:154)
              at org.infinispan.persistence.leveldb.LevelDBStore$1.call(LevelDBStore.java:297)
              at org.infinispan.persistence.leveldb.LevelDBStore$1.call(LevelDBStore.java:285)
              at java.util.concurrent.FutureTask.run(FutureTask.java:262)
              at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
              at java.util.concurrent.FutureTask.run(FutureTask.java:262)
              at org.infinispan.util.concurrent.WithinThreadExecutor.execute(WithinThreadExecutor.java:22)
              at java.util.concurrent.ExecutorCompletionService.submit(ExecutorCompletionService.java:181)
              at org.infinispan.executors.ExecutorAllCompletionService.submit(ExecutorAllCompletionService.java:31)
              at org.infinispan.persistence.leveldb.LevelDBStore.submitProcessTask(LevelDBStore.java:285)
              at org.infinispan.persistence.leveldb.LevelDBStore.process(LevelDBStore.java:260)
              at org.infinispan.persistence.manager.PersistenceManagerImpl.processOnAllStores(PersistenceManagerImpl.java:438)
              at org.infinispan.persistence.manager.PersistenceManagerImpl.processOnAllStores(PersistenceManagerImpl.java:420)
              at org.infinispan.iteration.impl.LocalEntryRetriever$1.run(LocalEntryRetriever.java:217)
              at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
              at java.util.concurrent.FutureTask.run(FutureTask.java:262)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
              at java.lang.Thread.run(Thread.java:745)
      

      Attachments

        Activity

          People

            wburns@redhat.com Will Burns
            rhn-support-afield Alan Field
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: