官网解释:

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. <未测>源码升级安装glibc和rpm升级glibc

    源码升级安装glibc和rpm升级glibc http://jacklin9.spaces.live.com/blog/cns!A891B52E1182AFB2!346.entry http://bl ...

  2. (转载)mysql 存在该记录则更新,不存在则插入记录的sql

    (转载)http://www.codesky.net/article/201003/105754.html 代码如下: INSERT table (auto_id, auto_name) values ...

  3. oracle 表查询(2)

    使用逻辑操作符号 问题:查询工资高于500 或者是岗位为MANAGER 的雇员,同时还要满足他们的姓名首字母为大写的J? or job = 'MANAGER') and ename LIKE 'J%' ...

  4. WCF—Binding

    原文地址:http://www.cnblogs.com/jams742003/archive/2010/01/13/1646379.html Binding描述了哪些层面的信息 一个Binding包含 ...

  5. Postman 安装 & 资料

    安装 下载地址: http://chromecj.com/web-development/2014-09/60/download.html 怎么在谷歌浏览器中安装.crx扩展名的离线Chrome插件? ...

  6. Beautiful Numbers

    http://codeforces.com/problemset/problem/300/C 题意:给你三个数a,b,n;求满足由a,b组成的n位的个数,且每个位置上的数之和也是用a,b组成; 解析: ...

  7. eclipse下开发简单的Web Service

    service部分 在eclipse下新建一个动态web项目 在项目中新建一个service类 编写SayHello类的代码 package org.sunny.service; //包不要引用错了 ...

  8. 初次了解CSS3

    什么是CSS,什么是CSS3? 非常简单,CSS代表"Casading Style Sheets",就是样式表,是一种替代并为网站添加样式的标记性语言.现在所使用的CSS基本是在1 ...

  9. bzoj1036 zjoi2008 树的统计 count

    填坑= =第一道裸树剖 #include<cstdio> #include<algorithm> #include<cstring> #include<cst ...

  10. 输入一个整形数组,数组里有正数也有负数。数组中连续的一个或多个整数组成一个子数组,每个子数组都有一个和。求所有子数组的和的最大值。要求时间复杂度为O(n)

    群里看到这道题,用python做了做, def find(array): v_sum = greatest = 0 for a in array: v_sum += a v_sum = 0 if v_ ...