обновление simple-spring-memcached до 4.1.1, вызывающее WrappedCacheException - PullRequest
0 голосов
/ 21 ноября 2018

Я недавно обновил simple-spring-memcached с версии 3.6.1 до 4.1.1.Однако после обновления этой версии я получаю WrappedCacheException всякий раз, когда мой код пытается извлечь значение из кэша.Я делюсь своим фрагментом кода ниже:

@Transactional
@Cacheable(value = CACHE_NAME, key = "#id")
@Override
public TicketModel validate(final String id) {
    TicketEntity ticketEntity = ticketEntityRepository.findOne(id);
    if (ticketEntity == null) {
        System.out.println("Ticket not found")
    }
    return something;
}

И мой компонент cacheManager выглядит так:

@Bean
public CacheManager cacheManager() throws Exception {
    List<SSMCache> cacheList = new ArrayList<>();

    CacheFactory cacheFactory;
    if (ELASTIC_CACHE_FACTORY.equals(cacheBean)) {
        cacheFactory = elastiCacheFactory();
    } else {
        cacheFactory = memCacheFactory();
    }

    Cache cache = cacheFactory.getObject();

    SSMCache aamCache = new SSMCache(cache, cacheTimeout, true);
    cacheList.add(aamCache);

    SSMCacheManager cacheManager = new SSMCacheManager();
    cacheManager.setCaches(cacheList);
    cacheManager.afterPropertiesSet();
    return cacheManager;
}

Точное исключение, которое я получаю, выглядит следующим образом:

    SEVERE: Servlet.service() for servlet [jersey-servlet] in context with path [/user-service-web] threw exception [com.google.code.ssm.spring.WrappedCacheException] with root cause
com.google.code.ssm.spring.WrappedCacheException
    at com.google.code.ssm.spring.SSMCache.logOrThrow(SSMCache.java:318)
    at com.google.code.ssm.spring.SSMCache.getValue(SSMCache.java:285)
    at com.google.code.ssm.spring.SSMCache.get(SSMCache.java:117)
    at org.springframework.cache.interceptor.AbstractCacheInvoker.doGet(AbstractCacheInvoker.java:68)
    at org.springframework.cache.interceptor.CacheAspectSupport.findInCaches(CacheAspectSupport.java:469)
    at org.springframework.cache.interceptor.CacheAspectSupport.findCachedItem(CacheAspectSupport.java:435)
    at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:336)
    at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:302)
    at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)

При каждом вызове метода findOne (id) я получаю WrappedCacheException, и код завершается ошибкой.Пожалуйста, помогите.

1 Ответ

0 голосов
/ 16 июня 2019

До 4.0.0 исключения, выданные из базового уровня кэша / клиента (например, IOExceptions и т. Д.), Были съедены объектом SsmCache.После 4.0.0 по умолчанию они выбрасываются на вызывающую сторону.Вы можете вернуться к предыдущему поведению, установив для флага "muteExceptions" значение true в бине SsmCache.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...