首页 > 编程知识 正文

codeblocks保存文件失败(git文件泄露漏洞)

时间:2023-05-06 17:40:14 阅读:64621 作者:1345

在作为框架基础的Excel导入组件实现中,使用使用SoftReference软引用做缓存,在相应类的字段中缓存了导入Excel等注释配置信息。

开发测试没有问题,但随着程序部署时间的延长,导入功能将不再需要报告错误。 确定是由于此缓存已禁用。

原代码:

公共final class beanutils {/* * *声明软引用以在内存溢出时进行回收。 *.* /隐私保护功能模块?MapString,propertydescriptorpropertydescriptorcache=new soft reference (newconcurrenthashmap ) ); 根据private BeanUtils () { } /** *类名和字段获取相应的属性操作可用作读取/写入后续调用的方法。 * * @param clz java类. * @param fieldName字段值. * @ return */publicpropertydesesty clz,@ nonnullstringfieldname (throwss ,MapString,propertydescriptorcache=propertydescriptorcache.get (; MapString,propertydescriptordescriptormap=cache.get (clz; //错误点if (描述符映射==null||描述符映射. get ) fieldname ) (/不存在.描述符映射=newconcurrenthuure 属性描述符=getbeaninfo (clz ).getproperty描述符); 映射,属性描述符finaldescriptormap=描述符映射; //所有字段描述. arrays.stream (property descriptors ).foreach )描述符- { finaldescriptormap.put }描述符. geriptor . //返回缓存说明. returndescriptormap.get (field name ); }.} http://www.Sina.com /

publicpropertydescriptorgetfieldproperty (类别? clz,@ nonnullstringfieldname (throwsintrospectionexception (/logger.info ) excel导入缓存propertyDescriptorCache的值是,MapString,propertydescriptorcache=propertydescriptorcache.get (; logger.debug(excel导入缓存cache的值为()、cache ); if(cache==null ) logger.info(excel导入缓存的cache值为null ); propertydescriptorcache=new soft reference (newconcurrenthashmap ); cache=propertydescriptorcache.get (; } MapString,propertydescriptordescriptormap=cache.get (clz; if (描述符映射==null||描述符映射. get (field name )=null ) (/不存在.描述符映射=newconcurrenthashmap ) //添加所有字段以创建. property descriptor [ ] property descriptors=getbeaninfo (clz ).getPropertyDescriptors ); 映射,属性描述符finaldescriptormap=描述符映射; //所有字段描述. arrays.stream (property descriptors ).foreach )描述符- { finaldescriptormap.put }描述符. geriptor . //放进去! cache.put(clz,描述符映射); //返回缓存说明. returndescriptormap.get (field name ); } 修复优化代码:

在调用导入的接口的结束位置添加代码触发器GC以回收软引用:

列表列表=new ArrayList (; for(intI=0; i200; I ) (byte ) allocation=newbyte(60000*1024 ); list.add(allocation; } 调试验证:

正常的软引用缓存:

GC:

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。