抑制Java Findbugs错误(EI_EXPOSE_REP) [英] Suppressing Java Findbugs error (EI_EXPOSE_REP)

查看:5390
本文介绍了抑制Java Findbugs错误(EI_EXPOSE_REP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Java gettor方法,如下所示:

I have a Java gettor method that looks like the following:

import java.util.Date;
//...
public Date getSomeDate() {
  return someDate;
}

,Findbugs报告说,这暴露了一个可变对象:可能会暴露内部表示返回对可变对象的引用。
我将代码更改为:

and Findbugs reports that this exposes a mutable object: "May expose internal representation by returning reference to mutable object". I changed the code to this:

import java.util.Date;
//...
public Date getSomeDate() {
  return new Date(someDate.getTime());
}

但Findbug仍然报告同样的漏洞。我还能做些什么来压制/解决这个问题?我在IntellJ 10 Findbugs插件中运行Findbugs 1.3.9。

but Findbug still reports the same vulnerability. What more can I do to suppress/fix this problem? I am running Findbugs 1.3.9 in the IntellJ 10 Findbugs plugin.

推荐答案

我只是意识到Findbugs分析了 / strong>代码( .class 文件),而不是源代码。重建和重新运行Findbugs后,问题消失了。

I just realized that Findbugs analyzes compiled code (.class files), not source code. After rebuilding and re-running Findbugs, the problem went away.

这篇关于抑制Java Findbugs错误(EI_EXPOSE_REP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆