当前位置:网站首页>Returned object not currently part of this pool
Returned object not currently part of this pool
2022-08-05 05:05:00 【绅士jiejie】
问题背景
使用了org.apache.commons.pool2依赖来做了一些池化操作,把一些已经实例化成功的客户端池化进了对象池,通过池化加快接口的查询效率。
问题分析
以上异常翻译过来就是【返回的对象当前不属于此池】,为什么会出现这种情况,因为导致这个报错的接口允许接收多个参数,然后一并返回结果,为了提升查询效率,所以引入了多线程查询,然后每个线程运行执行的底层逻辑方法中,有一个核心逻辑就是会去对象池中拿客户端对象,如果拿不到就会创建对象池同时生成客户端对象放进对象池中。正常情况下,是不会有这种异常的,问题在于多线程并发情况下,如果底层不加锁什么的,保证同步,那么很可能就会创建出多个对象池,但其实真正有引用关系的又是最后一个生成的对象池,因此前面创建出来的一些对象,在归还对象入池时,就会发现这对象不属于最后一个被引用的对象池,就会报出【Returned object not currently part of this pool】错误。
解决方案
1.如果没有什么懒加载的想法,那么建议可以在项目启动时初始化好对象池。
2.如果怕有些对象根本用不到,一开始就初始化出来,会导致资源浪费,那么建议试试加锁,不过这样的话就会影响到整体查询效率了。
边栏推荐
- LeetCode:1403. 非递增顺序的最小子序列【贪心】
- 【cesium】Load and locate 3D Tileset
- Mini Program_Dynamic setting of tabBar theme skin
- 说说数据治理中常见的20个问题
- 8.04 Day35-----MVC三层架构
- creo怎么测量点到面的距离
- Redis - 13. Development Specifications
- Flutter learning - the beginning
- Visibility of multi-column attribute column elements: display, visibility, opacity, vertical alignment: vertical-align, z-index The larger it is, the more it will be displayed on the upper layer
- Develop a highly fault-tolerant distributed system
猜你喜欢

8.04 Day35-----MVC three-tier architecture

University Physics---Particle Kinematics

【cesium】元素高亮显示

作业8.4 进程间的通信 管道与信号

App rapid development and construction experience: the importance of small programs + custom plug-ins

Flex layout frog game clearance strategy

Flutter real machine running and simulator running

Using QR codes to solve fixed asset management challenges
How to identify false evidence and evidence?

服务器磁盘阵列
随机推荐
LAB 信号量实现细节
Error creating bean with name ‘configDataContextRefresher‘ defined in class path resource
Develop your own node package
Detailed explanation of Mysql's undo log
结构光三维重建(一)条纹结构光三维重建
Day14 jenkins部署
Day019 Method overriding and introduction of related classes
类的底层机制
【学习笔记之菜Dog学C】动态内存管理之经典笔试题
大学物理---质点运动学
1068 Find More Coins
MySQL中控制导出文件后变为了\N有什么解决方案吗?
Mvi架构浅析
upload upload pictures to Tencent cloud, how to upload pictures
What is ASEMI photovoltaic diode, the role of photovoltaic diode
动力小帆船制作方法简单,电动小帆船制作方法
u-boot in u-boot, dm-pre-reloc
Redis哨兵模式配置文件详解
App快速开发建设心得:小程序+自定义插件的重要性
human weakness