[FindBugs分析记录]Potentially dangerous use of non-short-circuit logic
官网解释:
This code seems to be using non-short-circuit logic (e.g., & or |) rather than short-circuit logic (&& or ||). In addition, it seem possible that, depending on the value of the left hand side, you might not want to evaluate the right hand side (because it would have side effects, could cause an exception or could be expensive.
Non-short-circuit logic causes both sides of the expression to be evaluated even when the result can be inferred from knowing the left-hand side. This can be less efficient and can result in errors if the left-hand side guards cases when evaluating the right-hand side can generate an error.
大致意思是:
这段代用的是非简洁逻辑(例如,&或|),而不是简洁逻辑(&&或| |)。它似乎可能的是,只想根据左边的值,而不用不希望评估右边值(因为这会产生副作用,可能会导致异常或可能是昂贵的代价),非短路逻辑必须通过两侧的值来评估最终结果,这可能是低效率的,并且可能导致错误(左边表达式是正确的,右边表达式可能会是一个错误)。
所以这里的建议是:为了防止错误发生,建议使用简洁逻辑&&或||。
PS:
&称为逻辑与,只有两个操作数都是true,结果才是true。&&称为简洁与或者短路与,也是只有两个操作数都是true,结果才是true。但是如果左边操作数为false,就不计算右边的表达式,直接得出false。类似于短路了右边。
|称为逻辑或,只有两个操作数都是false,结果才是false。||称为简洁或或者短路或,也是只有两个操作数都是false,结果才是false。但是如果左边操作数为true,就不计算右边的表达式,直接得出true。类似于短路了右边。
[FindBugs分析记录]Potentially dangerous use of non-short-circuit logic的更多相关文章
- [FindBugs分析记录]Class defines clone() but doesn't implement Cloneable
官网解释: This class defines a clone() method but the class doesn't implement Cloneable. There are some ...
- [FindBugs分析记录]Redundant nullcheck of o,which is known to be non-null
官网解释: This method contains a redundant check of a known non-null value against the constant null. 这种 ...
- System.Web.HttpRequestValidationException: A potentially dangerous Request.F
ASP.NET .0验证请求 System.Web.HttpRequestValidationException: A potentially dangerous Request.F System.W ...
- ASP.NET 4.0 potentially dangerous Request.Form value was detected
A few days ago, while working on an ASP.NET 4.0 Web project, I got an issue. The issue was, when use ...
- [BILL WEI] A potentially dangerous Request.Path value was detected from the client 异常处理办法
我们在ASP.net中使用URL导向后, 我们在访问某个地址,或者打开某个系统页面的时候,就会报错误: A potentially dangerous Request.Path value was d ...
- A potentially dangerous Request.Form value was detected from the client问题处理
问题剖析: 用户在页面上提交表单到服务器时,服务器会检测到一些潜在的输入风险,例如使用富文本编辑器控件(RichTextBox.FreeTextBox.CuteEditor等)编辑的内容中包含有HTM ...
- ASP.NET 4.0验证请求 System.Web.HttpRequestValidationException: A potentially dangerous Request.F
System.Web.HttpRequestValidationException: A potentially dangerous Request.F 在使用类似eWebedtior 拷贝内容进去的 ...
- A potentially dangerous Request.Path value was detected from the client异常解决方案
场景: 当URL中存在“<,>,*,%,&,:,/”特殊字符时,页面会抛出A potentially dangerous Request.Path value was detect ...
- Fine报表权限流程分析记录
Fine报表权限流程分析记录 URL访问三种类型的报表:第一个:BI报表 例如: http://192.25.103.250:37799/WebReport/ReportServer?op=fr_bi ...
随机推荐
- CH Round #51 - Shinrein祭 #1
A.Phorni 题目:http://www.contesthunter.org/contest/CH%20Round%20%2351%20-%20Shinrein祭%20%231/Phorni 没做 ...
- SQLCMD的用法,使用CMD 执行sql语句
SQLCMD的用法,使用CMD 执行sql语句 SQLCMD 允许在Windows命令窗中通过命令行提示符运行脚本. 语法如下: sqlcmd [ { { -U <login id> ...
- 数学概念——A 几何概型
You are going from Dhaka to Chittagong by train and you came to know one of your old friends is goin ...
- 【Android Studio】No JVM installation found
如果没有配置好JDK的环境变量,启动Android Studio的时候会报错: 请参考我整理的博客文章<JDK的下载.安装和配置>,链接:http://www.cnblogs.com/du ...
- bzoj1251 序列终结者(Splay Tree+懒惰标记)
Description 网上有许多题,就是给定一个序列,要你支持几种操作:A.B.C.D.一看另一道题,又是一个序列 要支持几种操作:D.C.B.A.尤其是我们这里的某人,出模拟试题,居然还出了一道这 ...
- [Locked] Inorder Successor in BST
Inorder Successor in BST Given a binary search tree and a node in it, find the in-order successor of ...
- hdu 4632区间 dp
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4632 用点容斥原理转移状态, dp[i][j]=dp[i+1][j]+dp[i][j-1]-dp[i+ ...
- 【行业干货】ASOS:外来快时尚品牌的入华战 - 行业干货 - 京东内部论坛 - Powered by Discuz!
[行业干货]ASOS:外来快时尚品牌的入华战 - 行业干货 - 京东内部论坛 - Powered by Discuz! [行业干货]ASOS:外来快时尚品牌的入华战
- 使用JAVA与SmartFoxServer来实现游戏服务器概述
SmartFoxServer 是专门为Adobe Flash设计的跨平台socket服务器,让开发者高效地开发多人应用及游戏. 该服务器主要用来创建多玩家游戏.并提供强大的制作工具,各种回合制游戏和实 ...
- ECLIPSE里面SVN图标消失,文件状态不显示问题
ECLIPSE里面SVN状态图标消失,重新启动eclipse,重新导入工程也不能显示SVN状态图标.这多半是由于之前eclipse没有正常关闭引起的. 解决办法2个: 方法一:1. 在Window&g ...