I have a Java gettor method that looks like the following:
import java.util.Date;
//...
public Date getSomeDate() {
return someDate;
}
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());
}
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.
I just realized that Findbugs analyzes compiled code (.class
files), not source code. After rebuilding and re-running Findbugs, the problem went away.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With