new Rule: Date field set without clone
Brought to you by:
chrismair
If you take a java.util.Date on the constructor or setter, and you assign it to a field... then it *needs* to be cloned or some other thread/consumer could easily modify it.
Example:
class Foo {
Date x
Foo(Date x) {
this.x = x // violation
this.x = x.clone() // better
}
void setX(Date x) {
this.x = x // violation
this.x = x.clone() // better
}
}