当前位置:网站首页>代码扫描工具扫出的 Arrays.asList 使用BUG
代码扫描工具扫出的 Arrays.asList 使用BUG
2022-06-22 15:23:00 【夜七天】
在使用代码扫描工具之后,发现了代码
obj.andIn("id", Arrays.asList(arr));
此处提示有BUG,BUG信息为:
Bug: int[] passed to varargs method java.util.Arrays.asList(Object[]) in com.vs.api.impl.VsMpExaminationPaperServiceImpl.changePublish(Integer, Integer)
This code passes a primitive array to a function that takes a variable number of object arguments. This creates an array of length one to hold the primitive array and passes it to the function.
Rank: Scary (7), confidence: High
Pattern: VA_PRIMITIVE_ARRAY_PASSED_TO_OBJECT_VARARG
Type: VA, Category: CORRECTNESS (Correctness)
深入了解之后才发现:
使用 new ArrayList<>(Arrays.asList(arr))方式,Arrays.asList()的输出值会传递给ArrayList的构造器,那么会创建一个引用arr数组内元素的ArrayList,因此打乱的结果不会同步到arr数组去。如果直接使用Arrays.asList(arr)的结果,则结果会同步到arr数组。导致arr数组内元素也会被打乱。
边栏推荐
- jsp學習之(二)---------jsp脚本元素和指令
- JSP learning (2) -- JSP script elements and instructions
- 北京恢复堂食半月记:如何重燃门店经营烟火气
- Implementation classes with similar execution logic use the template pattern
- CUMT study diary - quick notes of digital image processing examination
- SAP ABAP BAPI-016
- Unable to connect after win10 WiFi is disconnected
- 面试知识点
- SAP价值流程&帮助请求流程-011
- 让代码优雅起来(学会调试+代码风格)
猜你喜欢

Conversion between numeric types and strings

Parts beyond the text are indicated by ellipsis

超出文本部分用省略号表示

机器学习笔记 - HaGRID—手势识别图像数据集简介

How to add a "security lock" to the mobile office of government and enterprises?

【C语言】深度剖析指针和数组的关系

SAP ABAP 子屏幕教程:在 SAP 中调用子屏幕-010

浙江创投圈的“半壁江山”,还得是国资

过气剧本杀,被露营“复活”

Idea installation summary
随机推荐
Jsp Learning (2) - - jsp script Elements and instructions
5 modes of IO model
Uniapp wechat applet obtains page QR code (with parameters)
SAP ABAP 中的 Smart Forms-014
jsp学习之开发环境的配置
for..of vs. for..in 语句
Runtime -- explore the nature of classes, objects, and classifications
What is restful and what rules should be followed when designing rest APIs?
6.gui (graphics, filling)
nio使用可写事件处理一次性写不完情况
JS method for judging data type of interview questions
SAP web service cannot log in to SOA management page with soamanager
SAP web service 无法使用 SOAMANAGER 登陆到SOA管理页面
使用IDM让百度云加速的方法
[C language] use of library function qsort
JSP学习之开发模式
Implementation classes with similar execution logic use the template pattern
变量
Parts beyond the text are indicated by ellipsis
Conversion between numeric types and strings