Class ExceptionWrapper<K,​V>

  • All Implemented Interfaces:
    org.cache2k.CacheEntry<K,​V>, org.cache2k.DataAware<K,​V>, org.cache2k.io.LoadExceptionInfo<K,​V>

    public class ExceptionWrapper<K,​V>
    extends Object
    implements org.cache2k.io.LoadExceptionInfo<K,​V>
    The exception wrapper is used in the value field of the entry, in case of an exception. This way we can store exceptions without needing additional memory, if no exceptions happen.

    The wrapper is immutable and implements cache entry, this way it can be used returned cache entry directly.

    Author:
    Jens Wilke
    • Constructor Detail

      • ExceptionWrapper

        public ExceptionWrapper​(ExceptionWrapper<K,​V> w,
                                long until)
        Copy constructor to set until.
      • ExceptionWrapper

        public ExceptionWrapper​(K key,
                                long now,
                                Throwable ex,
                                org.cache2k.io.ExceptionPropagator<K,​V> p)
      • ExceptionWrapper

        public ExceptionWrapper​(K key,
                                Throwable exception,
                                long loadTime,
                                Entry e,
                                org.cache2k.io.ExceptionPropagator<K,​V> p)
        Take over exception information from the entry, which either has no exception, an existing cached exception or a suppressed exception.
      • ExceptionWrapper

        public ExceptionWrapper​(K key,
                                Throwable exception,
                                long loadTime,
                                org.cache2k.io.LoadExceptionInfo w,
                                org.cache2k.io.ExceptionPropagator<K,​V> p)
    • Method Detail

      • getKey

        public K getKey()
        Specified by:
        getKey in interface org.cache2k.CacheEntry<K,​V>
        Specified by:
        getKey in interface org.cache2k.io.LoadExceptionInfo<K,​V>
      • getExceptionPropagator

        public org.cache2k.io.ExceptionPropagator<K,​V> getExceptionPropagator()
        Specified by:
        getExceptionPropagator in interface org.cache2k.io.LoadExceptionInfo<K,​V>
      • getException

        public Throwable getException()
        Specified by:
        getException in interface org.cache2k.CacheEntry<K,​V>
        Specified by:
        getException in interface org.cache2k.io.LoadExceptionInfo<K,​V>
      • getExceptionInfo

        public org.cache2k.io.LoadExceptionInfo<K,​V> getExceptionInfo()
        Specified by:
        getExceptionInfo in interface org.cache2k.CacheEntry<K,​V>
        Specified by:
        getExceptionInfo in interface org.cache2k.io.LoadExceptionInfo<K,​V>
      • getUntil

        public long getUntil()
        Specified by:
        getUntil in interface org.cache2k.io.LoadExceptionInfo<K,​V>
      • getLoadTime

        public long getLoadTime()
        Specified by:
        getLoadTime in interface org.cache2k.io.LoadExceptionInfo<K,​V>
      • getRetryCount

        public int getRetryCount()
        Specified by:
        getRetryCount in interface org.cache2k.io.LoadExceptionInfo<K,​V>
      • getSinceTime

        public long getSinceTime()
        Specified by:
        getSinceTime in interface org.cache2k.io.LoadExceptionInfo<K,​V>
      • toString

        public String toString()
        The exception wrapper instance is also used as CacheEntry directly and returned by Cache.getEntry(Object)
        Overrides:
        toString in class Object