Suppress Java findbugs errors (ei_expose_rep)

I have a Java gettor method, as follows:

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

And findbugs report that this exposes a mutable object: "the internal representation can be exposed by returning a reference to the mutable object." I changed the code to:

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

But findbug still reports the same vulnerability What else can I do to suppress / solve this problem? I run findbugs 1.3 in the intellj 10 findbugs plug-in nine

Solution

I just realized that findbugs analyzed the compiled code (. Class file), not the source code After rebuilding and rerunning findbugs, the problem disappears

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>