[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.
这种方法包含了一个称为非空对空值的不断重复检查。
什么代码会引起这个问题呢?先看下面:
public static boolean isNull(Object o) {
if (null == o)
return null == o;
if (o instanceof String) {
return StringUtils.isBlank((String) o);
}
return o == null;
}
倒数第二行代码:return o == null;执行到这一步的时候已经表明o不为空,现在就是拿一个已知非空的值和null进行比较,findbus认为这是种运行期存在安全隐患的代码。
这里的建议是:防止这种情况出现,直接返回false.
public static boolean isNull(Object o) {
if (null == o)
return null == o;
if (o instanceof String) {
return StringUtils.isBlank((String) o);
}
return false;
}
[FindBugs分析记录]Redundant nullcheck of o,which is known to be non-null的更多相关文章
- [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分析记录]Potentially dangerous use of non-short-circuit logic
官网解释: This code seems to be using non-short-circuit logic (e.g., & or |) rather than short-circu ...
- Fine报表权限流程分析记录
Fine报表权限流程分析记录 URL访问三种类型的报表:第一个:BI报表 例如: http://192.25.103.250:37799/WebReport/ReportServer?op=fr_bi ...
- PostgreSQL的基础数据类型分析记录-转
src:http://www.codeweblog.com/postgresql%E7%9A%84%E5%9F%BA%E7%A1%80%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E ...
- 获取登录验证码失败及前后端不同域导致session丢失问题分析记录
前言 前两周在把兄弟公司的几个服务部署到我们公司测试环境服务器的时候又遇到了不少问题,因为是前后端分离的项目,所以这次也同样遇到了跨域问题,解决方式也跟上一回的不一样,这里就再来分析记录一下. 登录验 ...
- sizzle分析记录:关于querySelectorAll兼容问题
querySelector和querySelectorAll是W3C提供的新的查询接口 目前几乎主流浏览器均支持了他们.包括 IE8(含) 以上版本. Firefox. Chrome.Safari.O ...
- Java GC分析记录
Java GC记录 近来.项目没有特别忙碌的时候,抽空看了下生产环境的项目运行状况,我们的项目一直运行速度不是很快,偶尔会出现卡顿的现象,这点给人的体验感觉也就不那么好了.先抛个测试环境截图(生产环境 ...
- Eureka 分析记录
本文是一些记录和想方法,分析大部分来自 http://www.iocoder.cn/Eureka/ 感兴趣的可以去看一下.
- linux日志朔源分析记录
lastlog 记录用户最后一次登录情况 只有root最近登录过 lastlog -u 用户名或者uid uid 直接在passwd文件中的低三位可以看到 lastb 记录用户用户登录失败的用户记录, ...
随机推荐
- HDOJ1253 胜利大逃亡 BFS
胜利大逃亡 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submiss ...
- 362. Design Hit Counter
这个傻逼题..我没弄明白 you may assume that calls are being made to the system in chronological order (ie, the ...
- Linux 下挂载硬盘的 方法
1. 添加磁盘,查看磁盘状况 [root@db1 /]# fdisk -l Disk /dev/sda: 10.7 GB, 10737418240 bytes 255 heads, 63 sector ...
- BootStrap-table 客户端分页和服务端分页的区别
当服务器没有对数据进行分页时,前端页面设计又要求进行分页,要分开来设置. 服务端分页: responseHandler: function(data){ return data.response; } ...
- 【Android - 框架】之RxJava的使用
RxJava算是最新最常用的,也是程序员们最喜欢的框架之一了. RxJava的核心由Observable(被观察者,事件源)和Subscriber(观察者)构成,Observable负责发出一系列事件 ...
- memcache基本讲解
Memcached技术 介绍: memcached是一种缓存技术, 他可以把你的数据放入内存,从而通过内存访问提速,因为内存最快的, memcached技术的主要目的提速, 在memachec 中维护 ...
- 触发器记录表某一个字段数据变化的日志 包括插入insert 修改update 删除delete 操作
本文参考:http://www.cnblogs.com/lyhabc/articles/3236985.html ,), ), ), ), ...
- DECIMAL Data Type
In MySQL, DECIMAL(M,D) and NUMERIC(M,D) are the same, and both have a precision of exactly M digits. ...
- Windows 8和CentOS 6.4(64)双系统硬盘安装教程
最近在笔记本上升级原来的系统Win7到Win8,同时又安装了CentOS 6.4(64)系统,实现双系统共存.着实折腾了一番,主要是CentOS6.4(64)的两个iso文件加起来5G多(其实只用第一 ...
- java中关于public class
在编写类的时候可以使用两种方式定义类: public class定义类: class定义类: 1,如果一个类声明的时候使用了public class进行了声明,则类名称必须与文件名称完 ...