murat8505 / projectlombok

Automatically exported from code.google.com/p/projectlombok
0 stars 1 forks source link

Lombok Builder not generating safe code for mutable (like java.util.Date) type class fields #787

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Please discuss feature requests first on
https://groups.google.com/forum/#!forum/project-lombok

What steps will reproduce the problem?
1. Have a java.util.Date type field variable
2. Put @Builder and @Value annotation
3. Build will throw exception(if Java FindBugs is enabled):
"May expose internal representation by returning reference to mutable object"

What is the expected output?
Lombok should generate code like below for mutable field variable:
public Builder withAcquireDate(final Date acquireDate) {
            this.acquireDate = new Date(acquireDate.getTime());
            return this;
}

What do you see instead?
it generate code like this:
public Builder withAcquireDate(final Date acquireDate) {
            this.acquireDate = acquireDate;
            return this;
}

What version of the product are you using?
1.16.x

On what operating system?
Linux 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 
GNU/Linux

Original issue reported on code.google.com by i.the.as...@gmail.com on 16 Feb 2015 at 12:53