官网解释:

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的更多相关文章

  1. [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 ...

  2. [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. 这种 ...

  3. System.Web.HttpRequestValidationException: A potentially dangerous Request.F

    ASP.NET .0验证请求 System.Web.HttpRequestValidationException: A potentially dangerous Request.F System.W ...

  4. 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 ...

  5. [BILL WEI] A potentially dangerous Request.Path value was detected from the client 异常处理办法

    我们在ASP.net中使用URL导向后, 我们在访问某个地址,或者打开某个系统页面的时候,就会报错误: A potentially dangerous Request.Path value was d ...

  6. A potentially dangerous Request.Form value was detected from the client问题处理

    问题剖析: 用户在页面上提交表单到服务器时,服务器会检测到一些潜在的输入风险,例如使用富文本编辑器控件(RichTextBox.FreeTextBox.CuteEditor等)编辑的内容中包含有HTM ...

  7. ASP.NET 4.0验证请求 System.Web.HttpRequestValidationException: A potentially dangerous Request.F

    System.Web.HttpRequestValidationException: A potentially dangerous Request.F 在使用类似eWebedtior 拷贝内容进去的 ...

  8. A potentially dangerous Request.Path value was detected from the client异常解决方案

    场景: 当URL中存在“<,>,*,%,&,:,/”特殊字符时,页面会抛出A potentially dangerous Request.Path value was detect ...

  9. Fine报表权限流程分析记录

    Fine报表权限流程分析记录 URL访问三种类型的报表:第一个:BI报表 例如: http://192.25.103.250:37799/WebReport/ReportServer?op=fr_bi ...

随机推荐

  1. bzoj2502

    学到很多知识的一道题目一开始读错题,后来发现是每条边必须至少访问一次明显是一个有下界的最小流首先是我自己脑补的比较渣的算法,可以无视:对于有下界的最小流,我不会做,但是我会做有下界的费用流,而且注意这 ...

  2. BZOJ 1048 [HAOI2007]分割矩阵

    1048: [HAOI2007]分割矩阵 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 623  Solved: 449[Submit][Status ...

  3. 贪心 uvaoj 11134 Fabled Rooks

    Problem F: Fabled Rooks We would like to place n rooks, 1 ≤ n ≤ 5000, on a n×n board subject to the ...

  4. cf703A Mishka and Game

    A. Mishka and Game time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  5. selenium webdriver python 操作Chrome浏览器

    Step1: 下载chromedriver. 下载路径: http://chromedriver.storage.googleapis.com/index.html 选择一个合适的下载即可.我下载的是 ...

  6. Servlet的一些细节(1)

    1.  Servlet程序必须映射到一个URL地址 由于客户端是通过URL访问web服务器资源,所以Servlet程序必须映射到一个URL地址.这个工作在web.xml文件中使用<servlet ...

  7. Web项目初始化过程

    在启动Web项目时,容器(比如Tomcat)会读web.xml配置文件中的两个节点<listener>和<contex-param>. 接着容器会创建一个ServletCont ...

  8. hadoop 2.0 详细配置教程(转载)

    转载: http://www.cnblogs.com/scotoma/archive/2012/09/18/2689902.html 作者:杨鑫奇 PS:文章有部分参考资料来自网上,并经过实践后写出, ...

  9. Unable to locate the Javac Compiler 解决办法

    在使用eclipse对maven项目进行编译打包(Run As->Maven install)时,报以下错误:[ERROR] Failed to execute goal org.apache. ...

  10. jeety and tomcat plugins In Maven

    (转自)maven jetty 插件使用 本机环境 JDK 7 Maven 3.2 Jetty 9.2 Eclipse Luna pom.xml 配置 在你的 pom.xml 文件中添加 jetty ...