oscache在压力测试时的异常

本文分析了在使用OSCache进行缓存更新时遇到的IllegalStateException异常。详细解释了错误发生的原因在于缓存状态不是预期的UPDATE_IN_PROGRESS,并提供了出现问题的代码片段。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

java.lang.IllegalStateException: Cannot complete cache update - current state (1) is not UPDATE_IN_PROGRESS
at com.opensymphony.oscache.base.EntryUpdateState.completeUpdate(EntryUpdateState.java:105)
at com.opensymphony.oscache.base.Cache.completeUpdate(Cache.java:797)
at com.opensymphony.oscache.base.Cache.putInCache(Cache.java:641)
at com.opensymphony.oscache.base.Cache.putInCache(Cache.java:614)
at com.opensymphony.oscache.general.GeneralCacheAdministrator.putInCache(GeneralCacheAdministrator.java:270)
at com.opensymphony.oscache.hibernate.OSCache.put(OSCache.java:54)


此异常常出现第一次缓存对象时
出现错误的代码如下
    /**
* Updates the state to <code>UPDATE_COMPLETE</code>. This should <em>only</em>
* be called by the thread that managed to get the update lock.
* @return the counter value after the operation completed
*/
public int completeUpdate() {
if (state != UPDATE_IN_PROGRESS) {
throw new IllegalStateException("Cannot complete cache update - current state (" + state + ") is not UPDATE_IN_PROGRESS");
}

state = UPDATE_COMPLETE;
return decrementUsageCounter();
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值